JPlus is a Java superset language running on the JVM that enhances developer productivity while staying fully compatible with the Java ecosystem.
π Why Support JPlus?
JPlus fills a unique gap in the Java ecosystem:
- Maintains 100% Java syntax compatibility
- Introduces null safety(?), null-safety operator(?.), boilerplate code generating syntax(apply), and Elvis Operator(?:) features
- Allows gradual adoption alongside existing Java code
- Compiles directly to plain Java code
π₯ Watch the demo video:
Currently, there is no other language that extends Java in this way while keeping the syntax familiar to Java developers.
β¨ Key Features
- Strict Null Checking β Prevent null reference errors at compile time
-
Null-safety Operator β Use
?.operators to safely access nullable variables without riskingNullPointerException - boilerplate code generating syntax β Replace common boilerplate like getters, setters, constructors, and builders without Lombok
-
Elvis Operator - Simplify null checks with
?:to provide default values when a variable is null
β
Example β β Combining ?. and ?: Operators
JPlus supports combining the null-safe access operator (?.) and the Elvis operator (?:)
to simplify complex null-handling logic into clean and concise expressions.
π Example β NullsafeWithElvisOperator.jplus
package jplus.example;
public class Main {
public static void main(String[] args) {
String? s1 = null;
String s2 = s1 ?: "jplus";
System.out.printf("the length of s1 : %d\n", s1?.length() ?: 0);
System.out.printf("the length of s2 : %d\n", s2.length());
}
}
-
s1is a nullable variable. -
s1 ?: "jplus"β assigns"jplus"ifs1is null. -
s1?.length() ?: 0β safely callslength()ons1, returns0ifs1is null. - By combining both operators, null handling becomes safe and concise.
β Output (Java code generated by JPlus)
package jplus.example;
public class Main {
public static void main(String[] args) {
String s1 = null;
String s2 = (((s1) != null) ? (s1) : "jplus");
System.out.printf(
"the length of s1 : %d\n",
(((((s1 != null) ? s1.length() : null)) != null)
? (((s1 != null) ? s1.length() : null))
: 0));
System.out.printf("the length of s2 : %d\n", s2.length());
}
}
The expression
s1?.length() ?: 0is translated into a nested conditional check in Java:
((s1 != null) ? s1.length() : null) != null ? ... : 0, ensuring safe execution.
β Example β‘ β Using apply for Data Class and Nested Class Boilerplate Elimination
JPlus introduces the apply keyword to replace common Java boilerplate code such as getters, setters, constructors, builders, and more.
It serves as a language-level alternative to Lombok annotations, offering a clean and declarative syntax.
π Example β ApplyStatement.jplus
package com.example;
apply data, constructor(required, all, no), builder;
apply {
User.Profile: getter, setter, equality, constructor(all);
}
public class User {
private String name;
private int age;
public class Profile {
String nickname;
}
}
-
data: Automatically generates getters, setters, equals(), hashCode(), and toString() -
builder: Generates a User.Builder class for fluent object creation -
constructors(required, all, no):Generates a constructor with all/required fields and a no-argument constructor -
equality: Generates equals() and hashCode() methods -
apply { User.Profile: ... }: Applies boilerplate generation specifically to the Profile inner class
β Output (Java code generated by JPlus)
package com.example;
//apply data, constructor(required, all, no), builder;
//apply {
// User.Profile: getter, setter, equality, constructor(all);
//}
public class User {
private String name;
private int age;
public User(String name, int age) {
this.name = name;
this.age = age;
}
public User() {}
public class Profile {
String nickname;
public Profile(String nickname) {
this.nickname = nickname;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Profile profile = (Profile) o;
return java.util.Objects.equals(nickname, profile.nickname);
}
@Override
public int hashCode() {
return java.util.Objects.hash(nickname);
}
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public void setName(String name) {
this.name = name;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return "User{" + "name=" + name+ ", " + "age=" + age + "}";
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return age == user.age
&& java.util.Objects.equals(name, user.name);
}
@Override
public int hashCode() {
return java.util.Objects.hash(name, age);
}
public static class Builder {
private String name;
private int age;
public Builder name(String name) {
this.name = name;
return this;
}
public Builder age(int age) {
this.age = age;
return this;
}
public User build() {
return new User(name, age);
}
}
public static Builder builder() {
return new Builder();
}
}
This allows developers to keep code DRY and expressive even with deeply nested structures.
π οΈ Current Status
- MVP (Minimum Viable Product) stage
-
IntelliJ Plugin 0.1 MVP Alpha released with:
- Syntax highlighting, code completion, and error checking
- Nullability checks
- Seamless integration with existing Java projects
πβ―Github repository
π₯ Watch the demo video
π₯ Download: intellij-plugin-0.1-mvp-alpha.zip
π‘ Why Your Support Matters
JPlus is actively developed and community contributions and sponsorships are critical:
- Help us improve stability, add features, and polish the language
- Gain early access to new releases and features
- Receive recognition as a valued sponsor and contributor
Your sponsorship accelerates development and helps bring safer, cleaner, and more productive Java development to the community.
πΈ How to Sponsor
Even a small contribution helps shape the future of JPlus!
Thank you for supporting JPlus β together, we can make Java development safer, more productive, and enjoyable. πβ―Github repository
Top comments (0)