Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Issue with ecj compiler and Java 11
Issue with ecj compiler and Java 11 [message #1858635] Wed, 12 April 2023 15:01 Go to next message
Eclipse UserFriend
Apache Cassandra project has the following ant task for many years.
Currently we use ecj version 4.6.1 with Java 8 (it does not support Java 11)
https://github.com/apache/cassandra/blob/trunk/build.xml#L1914-L1943
We use it for static analysis to warn on unsafe use of Autocloseable instances

I am trying to make it work with Java 11 as the Apache Cassandra project is going to drop the Java 8 maintenance for its next major version.

I updated ecj to 3.33.0, changed source and target to point to 11.

When I try to run the task it ends up with 57 000 errors and many of them are with the following error message:
Syntax error, parameterized types are only available if source level is 1.5 or greater

This tells me it tries earlier JDK versions? My JAVA_HOME points correctly to JDK11 and I verified the task is using the right ecj version jar too. I also realized that we actually need add-exports with JDK11 builds which according to the ecj help it is available but I am getting the following error when added in the eclipse-warnings task:
[java] Unrecognized option : --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED


I am trying to run this on Mac. I also tried to search for similar issues in the forum but I did not find anything related so far.
Please advise what do I miss? Thank you in advance!




Re: Issue with ecj compiler and Java 11 [message #1858638 is a reply to message #1858635] Thu, 13 April 2023 00:48 Go to previous messageGo to next message
Eclipse UserFriend
Both issues indicate that ecj picks an older default version as compliance, which I am guessing is 1.4. Which probably means it wasn't supplied a valid supported version.

Looking at the build.xml, I see that "${java.default} and ${ant.java.version} are being picked for -source and -target? Did you check what those values were?
Re: Issue with ecj compiler and Java 11 [message #1858687 is a reply to message #1858638] Sun, 16 April 2023 14:21 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for your response.
Yes, those values are correct:
https://github.com/apache/cassandra/blob/trunk/build.xml#L46 --> I substitute this with 11 and then ant.java.version picks up what I use for Cassandra and what I build successfully with Cassandra before running the eclpse-warnings task - again 11.

I also tried to substitute "${ant.java.version}" and "${java.version}" directly with the number "11" when running the task with JDK11. I get the same errors
I also just tried to add --release 11 but then I start getting plenty of "* cannot be resolved to a type"

[Updated on: Sun, 16 April 2023 14:26] by Moderator

Re: Issue with ecj compiler and Java 11 [message #1858688 is a reply to message #1858687] Sun, 16 April 2023 14:31 Go to previous messageGo to next message
Eclipse UserFriend
I forgot to mention that I figured out what was the issue behind:
[java] Unrecognized option : --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED

It seems I did a mistake and added initially
 <arg value="--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED" />

when it had to be:
 <arg value="--add-exports" />
            <arg value="java.rmi/sun.rmi.registry=ALL-UNNAMED" />

But this still did not help me with the other errors I pointed to.
Re: Issue with ecj compiler and Java 11 [message #1858698 is a reply to message #1858688] Mon, 17 April 2023 00:40 Go to previous messageGo to next message
Eclipse UserFriend
--release with JDK 11 is unlikely to work. It will only work with JDK 12 and above.

Anyway, I am unable to figure out what's going on. Looks like ECJ is already being fed what is necessary. So, it could be a bug. But just to be sure, can you run this once again with the -verbose option enabled?

Something I noticed when I looked at the build.xml - can you tell me what's inside ${ecj.properties} ?
Re: Issue with ecj compiler and Java 11 [message #1858714 is a reply to message #1858698] Mon, 17 April 2023 16:35 Go to previous message
Eclipse UserFriend
I tried -verbose, as requested, but I do not see anything to point me in a certain direction. I see the same lengthy lists of errors/warnings plus list of the compiled classes with marks - analyzing/reading/completing. Is there anything in particular I should pay attention to in the log?
I think the issue could be the compiler options we use.
So originally we added these properties many versions ago https://github.com/apache/cassandra/blob/trunk/eclipse_compiler.properties --> this is the file ${ecj.properties} points to
I've been adding and ignoring/disabling some that I found in CompilerOptions with the newest ecj and which weren't in the original list. I suspect I might have not updated them reasonably maybe? I will take closer look and experiment but telling me I need at least Java 1.5 sounds suspicious?
But first I have a few questions:
1) Can you point me to where the defaults for those options can be found? What are those assigned by default - warning/error/ignore/disabled?
2) Is this the difference between using ignore and disabled - ignore is used to suppress certain warnings and disabled is used to disable irrelevant features? I did not find a definition, are there any docs you can point me to, please?
Thank you for your help here!

[Updated on: Mon, 17 April 2023 18:32] by Moderator

Previous Topic:Java's for each loop
Next Topic:Print Predicate or Consumer type with Java proposal or Template
Goto Forum:
  


Current Time: Sun May 11 23:24:30 EDT 2025

Powered by FUDForum. Page generated in 0.04524 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top