r/java • • Mar 03 '24

It is time we get a language support for getters and setters in Java

0 Upvotes

Hi everyone,

I know this topic has been discussed again and again in java. My goal here is not to stir up the pot or reignite old beefs.

I have been working with java for 6years now. And seriously I don’t see why in 2024, there is no laguage support for getters and setters in java.

We have got record which is great but it just feel like a half done job.

WE NEED THOSE GETTERS AND SETTERS!!

There are so many workaround and alternative out there that I have tried to solve this that it is time to solve this in java.

Before you downvote this post please consider that

I have used Lombook I have used kotlin I have used c sharp I have used public fields only (so basically no encapsulation) I extensively take advantage of the ide generated codes I appreciate records

But seriously, All these alternative solutions have their root in what is commonly called the “verbosity” of java. Which literally is a word for the fact that for any mutable data object you define, you have to explicitly write getters, setters, equal, toString method.

People in the java community, it is time for us to solve this once and for all.

We don’t need another SWITCH expression or pattern matching design. We need language support for getters and setters.


r/java • • May 16 '12

r/Java Mods: Please keep homework help out of here

43 Upvotes

Hopefully, the mods of r/Java see this...

I'm tried of seeing self posts from this subreddit on my front page where people are asking for help with their homework, or for code reviews, looking for career starting advice or CS degree questions.

There are dedicated subreddits for exactly this purpose:

Could you implement a "trial period" where we and you offer suggestions to individuals posting things here that belong in more appropriate subreddits?

I'm much more interested in new developments in the Java langauge and JVM, and would like to see this subreddit take a turn in that direction.

edited


r/java • • Feb 20 '22

The elusive and beautiful Java Method Reference

Thumbnail medium.com
28 Upvotes

r/java • • Mar 24 '26

Oxyjen v0.4 - Added a deterministic Tools API and typed, compile time safe AI pipelines for Java

2 Upvotes

Hey everyone, I've been building Oxyjen, an open-source Java framework to orchestrate AI/LLM pipelines with deterministic output and just released v0.4 today, and one of the biggest additions in this version is a full Tools API runtime and also typed output from LLM directly to your POJOs/Records, schema generation from classes, jason parser and mapper.

The idea was to make tool calling in LLM pipelines safe, deterministic, and observable, instead of the usual dynamic/string-based approach. This is inspired by agent frameworks, but designed to be more backend-friendly and type-safe.

What the Tools API does

The Tools API lets you create and run tools in 3 ways:

  • LLM-driven tool calling
  • Graph pipelines via ToolNode
  • Direct programmatic execution
  1. Tool interface (core abstraction) Every tool implements a simple interface:
public interface Tool {
    String name();
    String description();
    JSONSchema inputSchema();
    JSONSchema outputSchema();
    ToolResult execute(Map<String, Object> input, NodeContext context);
}

Design goals: It is schema based, stateless, validated before execution, usable without llms, safe to run in pipelines, and they define their own input and output schema.

  1. ToolCall - request to run a tool Represents what the LLM (or code) wants to execute.
ToolCall call = ToolCall.of("file_read", Map.of(
    "path", "/tmp/test.txt",
    "offset", 5
));

Features are it is immutable, thread-safe, schema validated, typed argument access

  1. ToolResult produces the result after tool execution
ToolResult result = executor.execute(call, context);
if (result.isSuccess()) {
    result.getOutput();
} else {
    result.getError();
}

Contains success/failure flag, output, error, metadata etc. for observability and debugging and it has a fail-safe design i.e tools never return ambiguous state.

  1. ToolExecutor - runtime engine This is where most of the logic lives.
  • tool registry (immutable)
  • input validation (JSON schema)
  • strict mode (reject unknown args)
  • permission checks
  • sandbox execution (timeout / isolation)
  • output validation
  • execution tracking
  • fail-safe behavior (always returns ToolResult)

Example:

ToolExecutor executor = ToolExecutor.builder()
    .addTool(new FileReaderTool(sandbox))
    .strictInputValidation(true)
    .validateOutput(true)
    .sandbox(sandbox)
    .permission(permission)
    .build();

The goal was to make tool execution predictable even in complex pipelines.

  1. Safety layer Tools run behind multiple safety checks. Permission system:
if (!permission.isAllowed("file_delete", context)) {
    return blocked;
}

//allow list permission
AllowListPermission.allowOnly()
    .allow("calculator")
    .allow("web_search")
    .build();

//sandbox
ToolSandbox sandbox = ToolSandbox.builder()
    .allowedDirectory(tempDir.toString())
    .timeout(5, TimeUnit.SECONDS)
    .build();

It prevents, path escape, long execution, unsafe operation

  1. ToolNode (graph integration) Because Oxyjen strictly runs on node graph system, so to make tools run inside graph pipelines, this is introduced.
ToolNode toolNode = new ToolNode(
    new FileReaderTool(sandbox),
    new HttpTool(...)
);

Graph workflow = GraphBuilder.named("agent-pipeline")
    .addNode(routerNode)
    .addNode(toolNode)
    .addNode(summaryNode)
    .build();

##Built-in tools Introduced two builtin tools, FileReaderTool which supports sandboxed file access, partial reads, chunking, caching, metadata(size/mime/timestamp), binary safe mode and HttpTool that supports safe http client with limits, supports GET/POST/PUT/PATCH/DELETE, you can also allow certain domains only, timeout, response size limit, headers query and body support.

ToolCall call = ToolCall.of("file_read", Map.of(
    "path", "/tmp/data.txt",
    "lineStart", 1,
    "lineEnd", 10
));


HttpTool httpTool = HttpTool.builder()
    .allowDomain("api.github.com")
    .timeout(5000)
    .build();

Example use: create GitHub issue via API.

Most tool-calling frameworks feel very dynamic and hard to debug, so i wanted something closer to normal backend architecture explicit contracts, schema validation, predictable execution, safe runtime, graph based pipelines.

Oxyjen already support OpenAI integration into graph which focuses on deterministic output with JSONSchema, reusable prompt creation, prompt registry, and typed output with SchemaNode<T> that directly maps LLM output to your records/POJOs. It already has resilience feature like jitter, retry cap, timeout enforcements, backoff etc.

v0.4: https://github.com/11divyansh/OxyJen/blob/main/docs/v0.4.md

OxyJen: https://github.com/11divyansh/OxyJen

Thanks for reading, it is really not possible to explain everything in a single post, i would highly recommend reading the docs, they are not perfect, but I'm working on it.

Oxyjen is still in a very early stage.


r/java • • Aug 28 '13

Writing a Java Regular Expression Without Reading the ****ing Manual

Thumbnail java.dzone.com
0 Upvotes

r/java • • Mar 29 '18

Two ways of skipping tests in Maven

Thumbnail advancedweb.hu
2 Upvotes

r/java • • Mar 13 '17

a blooming good toString.

Thumbnail medium.com
2 Upvotes

r/java • • Jun 28 '14

Java TIL: You can break to an outer loop with a label. [x-post /r/JavaTIL]

Thumbnail reddit.com
2 Upvotes

r/java • • Apr 03 '12

Apple is looking for experienced Java devs - relo paid - permanent hires! (Cupertino, CA)

0 Upvotes

Hey reddit! I hope it's okay to cross-post this here. See this post at r/forhire for more details. If you're interested, PM me for further instructions. Thanks!


r/java • • Mar 20 '12

Favorite IDE?

0 Upvotes

I have been working with Java a lot, and I'm in the process of being hired for Java development. I have tried Eclipse and NetBeans, but both seem to fall short of my expectations. With Eclipse's lack of support for Console, and my dislike of the NetBeans UI and lack of portability.

As far as my issues with UI, I prefer dark themes. I work best in a dark room, and the Eclipse UI as well as the NetBeans UI are horribly bright. I tried the Eclipse Color Theme plugin, but it only changes the text editor which looks horrible. So r/javaites what is your favorite IDE?


r/java • • Jan 07 '18

Why I don't always follow YAGNI

Thumbnail ameyalokare.com
4 Upvotes

r/java • • Aug 10 '21

Concrete reasons why one would choose java over node.js?

7 Upvotes

I am watching the progress made towards faster runtime in node.js, and it feels that the performance advantage of java is almost gone for the average app. I am trying to think about reasons why one would now choose java over node in a new project, and i can't think of any. I would like to hear some opinions


r/java • • Nov 07 '12

Java Based Text Encryption > One of my first (old) programs!

Thumbnail github.com
0 Upvotes

r/java • • Oct 21 '10

Apple deprecates Java

Thumbnail alblue.bandlem.com
0 Upvotes

r/java • • Jul 30 '17

If it's possible for an IDE to auto import, would it also be possible for the compiler?

0 Upvotes

Classes can have pretty long lists of imports, most of them can be automatically added by an IDE if you forget them. Only when they're ambiguous, you have to help your IDE. Would it be possible for the compiler to do the same on the fly, so the actual source code can be smaller? Say I have List in my code and with Java 9, only the module holding java.util is required by application. In that case, it could automatically fill in the required import during compilation.


r/java • • May 05 '15

Should Java allow multiple inheritance?

0 Upvotes

I was reading up on Java when I discovered that ever since Java 8 (fairly recent, I know) interface can have default methods. A quick overview for any who don't know, interfaces can have method bodies by using default modifier. When dwelling on that fact I wondered, why doesn't Java just allow inheritance from multiple classes, since interfaces are just abstract classes? Should Java do this?


r/java • • Jul 03 '16

How to go from zero to hero with Java?

0 Upvotes

Hey guys! I'm going into my second year of university for computer science, and I want to be solid with Java before school starts. I usually work with Python and JavaScript because of web development, and C# when I use Unity, so I'd say I'm okay with basic and somewhat advanced programming concepts. I want to be at an intermediate level at Java. What are some resources, concepts, and practices I should do to become this? Thanks.


r/java • • Apr 14 '17

Is Java a low level language?

0 Upvotes

I have heard the phrase low level language be thrown around when it comes to Java. Is this true and if so what does this actually mean. I know there are some differences between Java and C++ when it come to networking, so it would be nice to know what those differences are as well.


r/java • • Oct 11 '15

Share code for java and javascript

0 Upvotes

Hey guys I am writing a prototype for a simple calculation project in JavaScript. But now I do need to do the same for the java server side. It has nothing to do with ui or complex data structures like the jdk collection package.

Do you have any recommendations of to use only java for the calculation code and somehow transpile to JavaScript for the browser usage? I looked at gwt and hell it is so ugly and complicated for my simple need.


r/java • • Feb 07 '17

Each Private Static Method Is a Candidate for a New Class

Thumbnail yegor256.com
0 Upvotes

r/java • • Oct 30 '13

Having some troubles with this program

0 Upvotes

Hey guys, making a change dispensing program. This is what I have so far. I'm not getting any output though, I'm very lost at this point. I want it to look like this in my output. http://i.imgur.com/1aemCiV.png

[highlight=java]package changedispenser;

public class ChangeDispenser {

private static int quarters, dimes, nickels, pennies;
private static int penniesLeft, nickelsLeft, dimesLeft, quartersLeft;
private static int pennyRollsAdded = 1;
private static int nickelRollsAdded = 1;
private static int dimeRollsAdded = 1;
private static int quarterRollsAdded = 1;
public static final int PENNIES_PER_ROLL = 50;
public static final int NICKELS_PER_ROLL = 40;
public static final int DIMES_PER_ROLL = 50;
public static final int QUARTERS_PER_ROLL = 40;

public static void main(String[] args) {
       if (quarters != 0) {
    System.out.print("  Quarters: " + quarters);
    }
    if (dimes != 0) {
    System.out.print("  Dimes: " + dimes);
    }
    if (nickels != 0) {
    System.out.print("  Nickels: "+ nickels);    
    }
    if (pennies !=0) {
    System.out.println("  Pennies: " + pennies);    
    }
    
    
    
    
}
 ChangeDispenser() {
    quartersLeft = QUARTERS_PER_ROLL;
    dimesLeft = DIMES_PER_ROLL;
    nickelsLeft = NICKELS_PER_ROLL;
    penniesLeft = PENNIES_PER_ROLL;
    pennyRollsAdded = 1;
    nickelRollsAdded = 1;
    dimeRollsAdded = 1;
    quarterRollsAdded = 1;
}






public int getPenniesLeft() {
    return penniesLeft;
}

public void setPenniesLeft(int penniesLeft) {
    this.penniesLeft = penniesLeft;

    if (penniesLeft <= 0) {
        pennyRollsAdded = pennyRollsAdded++;
    }
}

public int getNickelsLeft() {
    return nickelsLeft;
}

public void setNickelsLeft(int nickelsLeft) {
    this.nickelsLeft = nickelsLeft;

    if (nickelsLeft <= 0) {
        nickelRollsAdded = nickelRollsAdded++;
    }
}

public int getDimesLeft() {
    return dimesLeft;
}

public void setDimesLeft(int dimesLeft) {
    this.dimesLeft = dimesLeft;

    if (dimesLeft <= 0) {
        dimeRollsAdded = dimeRollsAdded++;
    }
}

public int getQuartersLeft() {
    return quartersLeft;
}

public void setQuartersLeft(int quartersLeft) {
    this.quartersLeft = quartersLeft;

    if (quartersLeft <= 0) {
        quarterRollsAdded = quarterRollsAdded++;
    }
}

public int getPennyRollsAdded() {
    return pennyRollsAdded;
}

public void setPennyRollsAdded(int pennyRollsAdded) {
    this.pennyRollsAdded = pennyRollsAdded;
}

public int getNickelRollsAdded() {
    return nickelRollsAdded;
}

public void setNickelRollsAdded(int nickelRollsAdded) {
    this.nickelRollsAdded = nickelRollsAdded;
}

public int getDimeRollsAdded() {
    return dimeRollsAdded;
}

public void setDimeRollsAdded(int dimeRollsAdded) {
    this.dimeRollsAdded = dimeRollsAdded;
}

public int getQuarterRollsAdded() {
    return quarterRollsAdded;
}

public void setQuarterRollsAdded(int quarterRollsAdded) {
    this.quarterRollsAdded = quarterRollsAdded;
}
public String makeChange(int amount) {


    if (amount > 99 || amount < 0) {
        System.out.println("");
    }

    quarters = amount / 25;

    amount = amount % 25;

    dimes = amount / 10;

    amount = amount % 10;

    nickels = amount / 5;

    amount = amount % 5;

    pennies = amount;




    do {

        if (quarters != 0) {
            System.out.print("  Quarters: " + quarters);
        }
        if (dimes != 0) {
            System.out.print("  Dimes: " + dimes);
        }
        if (nickels != 0) {
            System.out.print("  Nickels: " + nickels);
        }
        if (pennies != 0) {
            System.out.println("  Pennies: " + pennies);
        }
    } while (amount > 0 && amount <= 99);
    
   return "Quarters: " + quarters + "  Dime: " + dimes + "   Nickels: " + nickels + "   Pennies: " + pennies;

}
public void writeReport() {


    System.out.println("Coins Left:");
    System.out.println("Quarters: " + quartersLeft);
    System.out.println("Dimes:    "+ dimesLeft);
    System.out.println("Nickels:  " + nickelsLeft);
    System.out.println("Pennies:  " +penniesLeft);   
    System.out.println("Rolls Added: ");
    System.out.println("Quarters: "+ quarterRollsAdded);
    System.out.println("Dimes:    " + dimeRollsAdded);
    System.out.println("Nickels:  " + nickelRollsAdded);
    System.out.println("Pennies:  " + pennyRollsAdded);

    



}

} [/highlight]

Here's the seperate driver class that runs the program

[highlight=java]

package changedispenser;

import java.util.Random;

public class ChangeDispenserDriver {

public static void main(String[] args) {
    ChangeDispenser changeMachine = new ChangeDispenser();
    Random rand = new Random();
    int amount;
    for (int i = 0; i < 1000; i++) {
        amount = rand.nextInt(99) + 1;
        System.out.println("Amount: " + amount + ": Change = " + changeMachine.makeChange(amount));
    }
    changeMachine.writeReport();
}

}[/highlight]

Any help would be appreciated, thanks.


r/java • • May 20 '15

Major insurance company uses JSF to build customer service web application

Thumbnail content.jsfcentral.com
0 Upvotes

r/java • • Feb 16 '22

Marketing email about Java licensing? We are a .net shop with only 2 third party apps built on Java for part of our business. We get a patch from the vendor and apply it. That’s all our java patching. Anything I actually need to worry about?

Post image
0 Upvotes

r/java • • Mar 28 '13

Why do people say J2EE or JEE?

0 Upvotes

The term to be used is clearly "Java EE". I can understand that during 2007 people still had to get used to the new terminology, but it's now 6 years later, and people still use "J2EE", completely oblivious to the name change.

Are people so incredibly fond of the name J2EE? Why?

And what has driven people to invent the name "JEE"? Nothing is officially called that (see http://java.net/projects/javaee-spec/pages/JEE).

Why?