You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the feature
Simulates constexpr from C++11, build-time code-execution, from cppreference.com:
The @ConstExpr Annotation declares that it is possible to evaluate the value of the function or variable at compile time.
@ConstExprprivatestaticfinallongBUILD_TIME = System.currentTimeMillis();
@ConstExprprivatestaticfinalStringSIMPLE_NAME = MyClass.class.getSimpleName();
// is replaced with:privatestaticfinallongBUILD_TIME = 1739114746283L; // value is an example, depends on when you runprivatestaticfinalStringSIMPLE_NAME = "MyClass";
Describe the feature
Simulates constexpr from C++11, build-time code-execution, from cppreference.com:
The
@ConstExpr
Annotation declares that it is possible to evaluate the value of the function or variable at compile time.Describe the target audience
This feature would benefit Java developers developing mobile apps and games.
Additional context
Java libraries that implement this function:
https://github.com/junkdog/constexpr-java (unavailable in the maven repository)
https://github.com/Sipkab/jvm-constexpr (does not support maven/gradle)
Mention of this function
https://www.reddit.com/r/java/comments/5aci2a/constexprjava_buildtime_codeexecution_using_the/
https://discuss.kotlinlang.org/t/string-literals-way-to-compute-hashcode-at-compile-time/23745
https://youtrack.jetbrains.com/issue/KT-14652
https://discuss.kotlinlang.org/t/feature-request-compile-time-code-generator-annation/13719
The text was updated successfully, but these errors were encountered: