Lambda analyse hack no more working in java 12
To bring errors in compile time I'm using java function references to refer object based queries. Since it is not possible to lookup the referenced function name (in fact a stupid behaviour) I was forced to use a hack to get the referenced name.
Now it looks like the hack and even no other way exists to get the function name in java 12 (and maybe in earlier versions). I tested the current openjdk12 against my tool and it looks like it's not working.
Therefore I switched the way to save my code consistency. The alternative way is to generate classes which are containing information about the existing function names.
A maven plugin analyses existing classes and generates new ones. The generated classes will only be updated if the content is changes. In this way it is possible to commit the classes to the software repository.
To switch your project you need to add the plugin configuration to your pom:
<plugin>
<groupId>de.mhus.lib</groupId>
<artifactId>constgenerator-maven-plugin</artifactId>
<version>${mhulib.version}</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>const-generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>de.mhus.lib</groupId>
<artifactId>mhu-lib-annotations</artifactId>
<version>${mhulib.version}</version>
</dependency>
</dependencies>
</plugin>
Now it looks like the hack and even no other way exists to get the function name in java 12 (and maybe in earlier versions). I tested the current openjdk12 against my tool and it looks like it's not working.
Therefore I switched the way to save my code consistency. The alternative way is to generate classes which are containing information about the existing function names.
A maven plugin analyses existing classes and generates new ones. The generated classes will only be updated if the content is changes. In this way it is possible to commit the classes to the software repository.
To switch your project you need to add the plugin configuration to your pom:
<plugin>
<groupId>de.mhus.lib</groupId>
<artifactId>constgenerator-maven-plugin</artifactId>
<version>${mhulib.version}</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>const-generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>de.mhus.lib</groupId>
<artifactId>mhu-lib-annotations</artifactId>
<version>${mhulib.version}</version>
</dependency>
</dependencies>
</plugin>
And mark the concerning classes with the annotation @GenerateConst rebuild the project to generate the new classes. The will be generated direct to the corresponding root class and add a underscore to the class name.
Use the static fields to refer the function names.
Kommentare
Kommentar veröffentlichen