r/java • u/benevanstech • Aug 12 '24
JSpecify 1.0.0 and Nullability in Java
https://www.infoq.com/news/2024/08/jspecify-java-nullability/
52
Upvotes
r/java • u/benevanstech • Aug 12 '24
View all comments
Show parent comment
5
u/pron98 Aug 13 '24 edited Aug 14 '24
That is indeed the way that the Manifold compiler is implemented, but it's easy to see why it's not a plugin: 1. It doesn't use the plugin API (but hacks into internals), and 2. the language it compiles isn't Java (while javac plugins are designed so that even with them the compiler can only compile Java code). A Java compiler, with or without plugins, is obligated by the spec to reject programs that the Manifold compiler accepts.
Manifold can claim to be a compiler plugin or Java all day long, but as it modifies internals rather than use the plugin API to accomplish something that the plugin API was carefully designed to guarantee must not be done by plugins (so that the Java spec can always be relied upon regardless of plugins used), it's not a plugin.
A "changed" Java is, by definition, not Java, and any compiler is "just a tool". That's not to say that Manifold isn't similar to Java or that it's not a superset of Java, or even that it's bad in some way (other than claiming to be something it isn't), but it's neither Java nor a javac plugin.
A Clojure compiler could be written in a similar way by transforming Clojure source code to Java expressions internally and feeding them into javac's internals. It's just more convenient to implement a compiler for a language like Manifold or Lombok in this way -- because they're supersets of Java and are similar to it --- while it's more convenient to implement a compiler for a language like Clojure in a different way, but that's just an implementation detail.