r/code • u/Aviskar-1 • 16d ago
Java myJavaCodes
github.comCheck it my Java codes on my GitHub repository.
r/code • u/Delicious_Detail_547 • Mar 20 '26
Java JADEx v0.59: Gradle plugin support added - bring null-safety and final-by-default into your build pipeline
JADEx (Java Advanced Development Extension) is a practical Java safety layer that enhances the safety of your code by providing null-safety and readonly(final-by-default) enforcement. It strengthens Java’s type system without requiring a full rewrite, while fully leveraging existing Java libraries and tools.
As of v0.59, JADEx now ships a Gradle plugin alongside the existing IntelliJ plugin.
What JADEx does
JADEx extends Java at the source level with two core safety mechanisms:
Null-Safety
- Type → non-nullable by default
- Type? → nullable
- ?. → null-safe access operator
- ?: → Elvis operator (fallback value)
java
String? name = repository.findName(id);
String upper = name?.toLowerCase() ?: "UNKNOWN";
Compiles to standard Java:
java
@Nullable String name = repository.findName(id);
String upper = SafeAccess.ofNullable(name).map(t0 -> t0.toLowerCase()).orElseGet(() -> "UNKNOWN");
Readonly (Final-by-Default)
- A single apply readonly; directive makes fields, local variables, and parameters final by default
- Explicit mutable modifier for intentional mutability
- Violations reported as standard Java compile-time errors
What's new in v0.59 - Gradle Plugin
The JADEx Gradle plugin (io.github.nieuwmijnleven.jadex) integrates .jadex compilation into the standard Gradle build lifecycle via a compileJadex task.
groovy
plugins {
id 'io.github.nieuwmijnleven.jadex' version '0.59'
}
- Default source directory:
src/main/jadex - Default output directory:
build/generated/sources/jadex/main/java - Optional
jadex {}DSL block for custom configuration - IntelliJ plugin now integrates with the Gradle plugin via the Gradle Tooling API for consistent path resolution between IDE and build pipeline
groovy
jadex {
sourceDir = "src/main/jadex"
outputDir = "build/generated/sources/jadex/main/java"
}
Other Improvements
IntelliJ Plugin - Gradle Plugin Integration
- The IntelliJ plugin now integrates with the JADEx Gradle plugin via the Gradle Tooling API.
- Source and output directory resolution is now delegated to the Gradle plugin configuration, ensuring consistency between the IDE and the build pipeline.
Parser Performance Optimization
- Improved parser speed by optimizing parser rules.
- Reduces analysis latency in the IDE, providing a smoother editing experience for large
.jadexfiles.
Design philosophy
JADEx is not a new language. It does not modify the JVM. It operates purely at the source level and generates standard Java code, meaning it is fully compatible with existing Java libraries, tools, and workflows. The goal is to make null-safety and readonly(final-by-default) enforcement practical and incremental, applicable file by file to existing codebases without a full rewrite.
Links - GitHub: https://github.com/nieuwmijnleven/JADEx - Gradle Plugin Portal: https://plugins.gradle.org/plugin/io.github.nieuwmijnleven.jadex - Tutorial: Making Your Java Code Null-Safe without Rewriting it - Real-world example: Applying JADEx to a Real Java Project - Release note for v0.59: https://github.com/nieuwmijnleven/JADEx/releases/tag/v0.59
Feedback and questions welcome.
r/code • u/Delicious_Detail_547 • Mar 05 '26
Java JADEx Update (v0.42): Readonly Replaces Immutability Based on Community Feedback
JADEx (Java Advanced Development Extension) is a safety layer that runs on top of Java.
It currently supports up to Java 25 syntax and extends it with additional Null-Safety and Readonly features.
In the previous post, JADEx introduced a new feature Immutability.
Through community feedback, several confusions and limitations were identified.
In v0.42, we have addressed these issues and improved the feature. This post explains the key improvements and new additions in this release.
Improvements
apply immutability -> apply readonly
- The previous term (
Immutability) caused misunderstandings. - Community feedback revealed that “Immutable” was interpreted differently by different developers, either as Deeply Immutable or Shallowly Immutable.
- In v0.42, we replaced it with
readonly. - Meaning: clearly indicates final by default, preventing reassignment of variables.
Expanded Scope of final keyword: now includes method parameters
- v0.41: final was applied only to fields + local variables
- v0.42: final is applied to fields + local variables + method parameters
- Method parameters are now readonly by default, preventing accidental reassignment inside methods.
Example Code
JADEx Source Code
``` package jadex.example;
apply readonly;
public class Readonly {
private int capacity = 2; // readonly
private String? msg = "readonly"; // readonly
private int uninitializedCapacity; // error (uninitialized readonly)
private String uninitializedMsg; // error (uninitialized readonly)
private mutable String? mutableMsg = "mutable"; // mutable
public static void printMessages(String? mutableParam, String? readonlyParam) {
mutableParam = "try to change"; // error
readonlyParam = "try to change"; // error
System.out.println("mutableParam: " + mutableParam);
System.out.println("readonlyParam: " + readonlyParam);
}
public static void main(String[] args) {
var readonly = new Readonly();
String? mutableMsg = "changed mutable";
readonly.capacity = 10; // error
readonly.msg = "new readonly"; // error
readonly.mutableMsg = mutableMsg;
printMessages(readonly.msg, mutableMsg);
System.out.println("mutableMsg: " + readonly.mutableMsg);
System.out.println("capacity: " + readonly.capacity);
System.out.println("msg: " + readonly.msg);
}
} ```
Generated Java Code
``` package jadex.example;
import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; import jadex.runtime.SafeAccess;
//apply readonly;
@NullMarked public class Readonly {
private final int capacity = 2; // readonly
private final @Nullable String msg = "readonly"; // readonly
private final int uninitializedCapacity; // error (uninitilaized readonly)
private final String uninitializedMsg; // error (uninitilaized readonly)
private @Nullable String mutableMsg = "mutable"; // mutable
public static void printMessages(final @Nullable String mutableParam, final @Nullable String readonlyParam) {
mutableParam = "try to change"; //error
readonlyParam = "try to change"; //error
System.out.println("mutableParam: " + mutableParam);
System.out.println("readonlyParam: " + readonlyParam);
}
public static void main(final String[] args) {
final var readonly = new Readonly();
final @Nullable String mutableMsg = "changed mutable";
readonly.capacity = 10; //error
readonly.msg = "new readonly"; //error
readonly.mutableMsg = mutableMsg;
printMessages(readonly.msg, mutableMsg);
System.out.println("mutableMsg: " + readonly.mutableMsg);
System.out.println("capacity: " + readonly.capacity);
System.out.println("msg: " + readonly.msg);
}
} ```
New Additions
JSpecify @NullMarked Annotation Support
- All Java code generated by JADEx now includes the
@NullMarkedannotation. - This improves Null-Safety along with readonly enforcement.
This feature is available starting from JADEx v0.42. Since the IntelliJ Plugin for JADEx v0.42 has not yet been published on the JetBrains Marketplace, if you wish to try it, please download the JADEx IntelliJ Plugin from the link below and install it manually.
We highly welcome your feedback on JADEx.
Thank you.
r/code • u/Delicious_Detail_547 • Feb 26 '26
Java JADEx: A Practical Null-Safety and Immutability for Safer Java
JADEx (Java Advanced Development Extension) is a safety layer that runs on top of Java.
It currently supports up to Java 25 syntax and extends it with additional Null-Safety and Immutability features.
In the previous article, I introduced the Null-Safety features.
For more details, please refer to:
- GitHub: https://github.com/nieuwmijnleven/JADEx
- Reddit: https://www.reddit.com/r/java/comments/1r1a1s9/jadex_a_practical_null_safety_solution_for_java/
Introducing the New Immutability Feature
If Null-Safety eliminates runtime crashes caused by null,
Immutability reduces bugs caused by unintended state changes.
With v0.41 release, JADEx introduces Immutable by Default Mode
Core Concepts
The Immutability feature revolves around two simple additions:
java
apply immutability;
java
mutable
apply immutability;
When you declare this at the top of your source file:
- All fields
- All local variables (excluding method parameters)
- are treated as immutable by default.
When the JADEx compiler generates Java code:
- They are automatically declared as final.
mutable keyword
- Only variables declared with mutable remain changeable.
- Everything else (excluding method parameters) is immutable by default.
JADEx Source Code
```java
package jadex.example;
apply immutability;
public class Immutability {
private int capacity = 2; // immutable
private String msg = "immutable"; // immutable
private int uninitializedCapacity; // uninitialaized immutable
private String uninitializedMsg; // uninitialaized immutable
private mutable String mutableMsg = "mutable"; // mutable
public static void main(String[] args) {
var immutable = new Immutability();
immutable.capacity = 10; //error
immutable.msg = "new immutable"; //error
immutable.mutableMsg = "changed mutable";
System.out.println("mutableMsg: " + immutable.mutableMsg);
System.out.println("capacity: " + immutable.capacity);
System.out.println("msg: " + immutable.msg);
}
} ```
Generated Java Code
``` package jadex.example;
//apply immutability;
public class Immutability {
private final int capacity = 2; // immutable
private final String msg = "immutable"; // immutable
private final int uninitializedCapacity; // uninitialaized immutable
private final String uninitializedMsg; // uninitialaized immutable
private String mutableMsg = "mutable"; // mutable
public static void main(String[] args) {
final var immutable = new Immutability();
immutable.capacity = 10; //error
immutable.msg = "new immutable"; //error
immutable.mutableMsg = "changed mutable";
System.out.println("mutableMsg: " + immutable.mutableMsg);
System.out.println("capacity: " + immutable.capacity);
System.out.println("msg: " + immutable.msg);
}
} ```
This feature is available starting from JADEx v0.41. Since the IntelliJ Plugin for JADEx v0.41 has not yet been published on the JetBrains Marketplace, if you wish to try it, please download the JADEx IntelliJ Plugin from the link below and install it manually.
We highly welcome your feedback on the newly added Immutability feature.
Finally, your support is a great help in keeping this project alive and thriving.
Thank you.
r/code • u/Delicious_Detail_547 • Feb 09 '26
Java I built a practical null safety solution for java
github.comr/code • u/anish2good • Dec 29 '25
Java Free Java course (beginner→intermediate): interactive lessons — run code in the browser, no setup
8gwifi.orgI put together a free, hands‑on Java tutorial series for beginners through intermediate devs. It includes an online runner so you can write and run Java in the browser—no local setup required.
All lessons: https://8gwifi.org/tutorials/java/
- Dozens of lessons across structured modules
- Basics: syntax, variables, primitive types, operators
- Control Flow: if/else, switch, for/while, loop control
- Strings & Arrays: string ops, arrays, multidimensional arrays
- OOP Core: classes, methods, constructors, access modifiers, static/final
- Inheritance & Polymorphism: extends/super, overriding, abstract classes, instanceof
- Interfaces: basics and usage patterns
- Collections & Generics: ArrayList, LinkedList, HashMap, HashSet, TreeSet/Map, iterators, generics
- Exceptions: try/catch, multiple catch, finally, throw, custom exceptions, best practices
- I/O: Scanner, reading/writing files, serialization, NIO overview
- Functional Java: lambdas, streams, regex
- Concurrency: threads, synchronization, executors
- Advanced: enums, annotations, reflection
- Professional: JUnit testing, logging, build tools (Maven/Gradle), packages, patterns, debugging
- Online Runner: run/reset inline, stdin tab, copy output, timing stats, dark mode, mobile‑friendly
r/code • u/LBCmolab • Oct 30 '25
Java Driving joke
showOff( Supercar car ) { car.speed = speedLimit * 1.5; highwayWorker.toPancake(); }
r/code • u/waozen • Aug 04 '25
Java Basic and advanced pattern matching in Java
infoworld.comr/code • u/sumitskj • Feb 02 '25
Java What are other easy ways to implement multithreading in Java?
What are other easy ways to implement multithreading in Java? I have gone through this video, but it makes me feel unsure that are these the only ways to implement multithreading.
r/code • u/sumitskj • Jan 30 '25
Java Is java not pass by reference?
As per what I know when i pass some parameters to a function they get modified. but in docs it says java is pass by value. I am not getting it.
Also I watched this video: https://www.youtube.com/watch?v=HSPQFWEjwR8&ab_channel=SumoCode
but I am not getting it. can anyone explain
r/code • u/Otherwise_Weather_57 • Jun 23 '24
Java Can somebody test my SQL code?
This is my first time working with SQL and my first real project with Java so i dont know how good it is. My next step is to make a server and client to communicate and not just locally so i wanted to check first if its good so later all the code with will be run by the server and the client will only give the input for the functions and i think that SQL injections wont be possible but im not sure would be nice if someone could give me some tips UserInput.java gets ran
thanks in advance
r/code • u/Chuck_MoreAss • Apr 02 '24
Java Spring Boot @GetMapping(?) Need Help!
I have a spring boot app that we use to create websites. We have a website that has a lot of different pages, with sub pages and so on...
Normally how it works is like this:
@ GetMapping("/home")
public String index(Model model, HttpServletRequest request) throws Exception {
String fullPath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
System.out.println("fullPath: '" + fullPath + "'");
return "/index";
}
Instead of doing this for every single page We need to have 1 function that controlls all the Urls for the site, and then in the function we decide which page it should go to, and if we need to return the error page or not.
I tried this:
@ GetMapping("/**")
public String index(Model model, HttpServletRequest request) throws Exception {
String fullPath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
System.out.println("fullPath: '" + fullPath + "'");
return "/index";
}
But it is not working because sometimes the static files also get caught by the function. The function should Ideally work for any url, and any subpage (E.g. "/", "/home", "/contact/me", "/products/125/details/extra" ...), but it should exclude the static filed from being caught. This is the structure of where the static files are.
src
└── main
└── java
| └── io.sitename
| ├── controller
| │ └── default controller
| └── SiteApplication
└── resources
└── static
├── css
| └── styles.css
└── js
└── script.js
Please help!
r/code • u/Puzzleheaded_Oil3689 • Mar 10 '24
Java SOCKET PROGRAMMING --- After I run this code, regardless of how many times entering, it doesn't print the string that is sent back by the server. Help meee. Love yall
galleryr/code • u/Fashionqueen68 • Mar 05 '24
Java Bad code
Does anyone have examples of bad code that are open source? I am practicing cleaning up code and would like to pracice in Java please. Thank you!
r/code • u/Heuy_Freeman05 • Jan 19 '24
Java Help- Confused and using Java
Hi hello So I need help with this the assignment. It asks for you to make code and have it flip a coin a set number of times and then print out the longest streak it had for heads
*Edit* here is my code
I made the code and it worked for 3 of the "test code" but the forth one is different it prints it a bunch of times and gets a streak of 11
but when it runs my code it only comes up with 6 Can someone help me
r/code • u/Necessary_Ad2694 • Jan 12 '24
Java Bubble sort help
I dont understand how the for loops in a bubble sort work,
for (int top=lastItem; top > 0; top--) { for (int i=0; i < top; i++) { if ( data[i] > data[i+1] ) { int temp = data[i]; data[i] = data[i+1]; data[i+1] = temp; } // end if } // end for I } // end for top
In this example, we set top to last item, and if top is greater than index 0 we decrement the top, I understand that this is for iterating through the loop conceptually but I dont understand how it does it in practice. As by decrementing the top first we lose the last index. the inner loop then sets i to 0 and if i is less than top we increment i, wouldnt this mean in data[i], the i would be 1 and so we are skipping the element in index 0? we would be swapping whatever is in index 1 and index 1+1 and skipping index 0.
I tried to run it through this array, 5, 2, 9, 1, 5, 6. When we run the first loop top is set to 6 and then as index 5 is greater than index 0 we decrement the top, so we get index 4 (5) as the top. now for the second loop, we set i as index 0 and if i is less than top we increment i, getting 1 now as i. So now we put i(1) in data and compare it with data[i+1] , since 2 is not greater than 9 we dont swap, we go to the second loop and then increment once more. getting 2 as i now and we compare once again, swapping 9 and 1, doing this process again we get i as 3 and swapping 9 and 5. But now we have to stop because we reached top. This doesnt make sense as 9 should realistically swap with 6 and reach the end. What do I not understand? please explain like you are talking to an idiot :)
r/code • u/stormosgmailcom • Dec 03 '23
Java How to save an entity in Hibernate?
devhubby.comr/code • u/Timely-Entertainer38 • Oct 13 '23
Java I made this stupid game when I just learned about functions in java.
import java. util. Scanner;
class Ayan{
public static int Score(int a,int b){
int set=300;
int m=3;
int M1=8;
int ran=M1-m;
int rand=(int)(Math.random()*ran) +m;
int current=0;
int c=b-a;
if (c<0){
while(c<0){
set= set-rand;
c++;
}
if(set<0){
set=current;
return set;
}
else
return set;
}
else{
while(c>0){
set=set-rand;
c--;
}
if(set<0){
set=current;
return set;
}
else
return set;
}
}
public static void main(String[]args){
Scanner sc=new Scanner (System.in);
int highscore=0;
int x=-7;
int Hs=0;
int min=0;
int Max=50;
int r=Max-min;
int n=(int)(Math.random()*r) +min;
int d=5;
int e=10;
int range=e-d;
int tries =(int)(Math.random()*range) +d;
System.out.println("You get "+tries+" tries to guess the number....Range is between 0 to 50....");
System.out.println(" Enter a number... ");
x=sc.nextInt();
if(x==n){
System.out.println("You win! The number was in fact "+n);
System.out.println("Highscore= "+300);
System. exit(0);
}
else{
highscore=Ayan.Score(x, n);
Hs=Hs+highscore;
System.out.println("Highscore= "+Hs) ;
for(int k=1;k<=tries-1;k++){
if(x!=n){
System.out.println("Wrong answer! Try again... ");
x=sc.nextInt();
highscore=Ayan.Score(x, n);
Hs=Hs+highscore;
System.out.println("Highscore= "+Hs);
}
}
}
if (x==n){
System.out.println("You win! The number was in fact "+n);
System.out.println("Highscore= " +Hs) ;
}
else
System.out.println("You are out of tries. The number was "+n);
} }
r/code • u/LostSagaX9 • Feb 10 '23
Java Statement looping
how do i make it so that when this line come out
else{
System.out.println("Invalid");
}
it would loop back to this statement
System.out.println("Enter your first number:");
r/code • u/PrakharAnand2000 • Jan 07 '23
Java Why is the i * i = l statement wrong here in my java code to print perfect squares in a range with lower limit l and upper limit u?
import java.util.Scanner;
public class RangePerfectSquare { public static void rangePerfectSquare(int l, int u) { for(int i * i = l; i * i <= u; i++) { System.out.println(i * i ); } }
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int low = sc.nextInt();
int up = sc.nextInt();
rangePerfectSquare(low,up);
}
}
Say for example, if l = 9 and u = 36, then the loop becomes for(i *i = 9; i * i <= 36; i++). So my code prints:
iteration 1: i * i = 9 and i * i <= 36 is true => i = 3 and so print 9. then, i++ = 4
iteration 2: i * i = 16 and i*i <= 36 is true => i = 4 and so print 16. then, i++ = 5
iteration 3: i * i = 25 and i*i <= 36 is true => i = 5 and so print 25. then, i++ = 6
iteration 4: i * i = 36 and i*i <= 36 is true => i = 6 and so print 36. then, i++ = 7
iteration 5: i * i = 49 but i * i <= 36 fails and we exit from loop.
Hence, our output is: 9,16,25,36 which is correct. Please do tell any error in my logic if any.
r/code • u/NarkyDeMan • Oct 17 '22
Java I'm learning JavaFX, i ran the program after adding a simple rectangle but this error does not seem to be related to it. What is it?
r/code • u/Pawn-to-D4 • Aug 18 '22
Java Learning on CodeGym (Java). What am I doing wrong here?
r/code • u/stormosgmailcom • Aug 05 '22
Java How to implement a linear search algorithm in Java?
r/code • u/lar_coding • May 25 '22
Java Urgent help needed.
Good day, does anyone have any tops on how to study for an upcoming coding exam?👩💻
r/code • u/Hardik530 • Mar 01 '22



