Bug 390446 - Set "Incompatible required binaries" build path problem to "Warning" by default
Summary: Set "Incompatible required binaries" build path problem to "Warning" by default
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.3 M6   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-26 10:15 EDT by Markus Keller CLA
Modified: 2013-03-12 08:41 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2012-09-26 10:15:30 EDT
Mixed setups are always problematic and will bite the user sooner or later. I often see issues were a project is set up for J2SE-1.4, but developers compile against a 1.5 JRE. They often use new APIs and only realize their fault when users complain about NoSuchMethodExceptions.

JavaCore#CORE_INCOMPATIBLE_JDK_LEVEL should be set to "warning" by default".
Comment 1 Srikanth Sankaran CLA 2012-10-03 03:16:30 EDT
I plan to make to make this change only in the BETA_JAVA8 branch.
Any disagreements ?
Comment 2 Dani Megert CLA 2012-10-03 03:51:09 EDT
(In reply to comment #1)
> I plan to make to make this change only in the BETA_JAVA8 branch.
> Any disagreements ?

Yes. We should do this for 4.3 and maybe even 3.8.2. Note that we already show a warning on the 'Java Compiler' properties page for such a setup. And we also have 'Warning' as default if there's no strictly compatible JRE for the chosen EE.
Comment 3 Srikanth Sankaran CLA 2012-10-03 04:32:46 EDT
Manoj, please take a look. First please prepare a patch for 4.3. TIA.
Comment 4 Srikanth Sankaran CLA 2012-10-16 02:51:36 EDT
Dani, I worry that this is create gazillions of warnings in the automated
tests suites of various SDK projects. What do you suggest as a mitigation
strategy ? Is there a way we can figure out whether junits are running or
not and according to initialize it to ignore vs warning ? If we were do
invent a new system property or such, is there a ready place where it is
easily defined ? 

Should there be a heads up to eclipse-dev to expect a new warning in
setups that use a different JRE ?
Comment 5 Dani Megert CLA 2012-10-16 04:38:06 EDT
(In reply to comment #4)
> Dani, I worry that this is create gazillions of warnings in the automated
> tests suites of various SDK projects. 

Very good point Srikanth. And actually this, not just affects test projects: All projects which are still on 1.4 will get that warning (because 'org.eclipse.core.runtime' is at 1.5 now). And they will not only get one warning but one per required bundle that has BREE > 1.4.


In addition I found something strange when testing it now:
1. create a Java project with compliance 1.4 and 1.4 JRE (or J2SE-1.4 EE)
2. set incompatible required binaries to Warning
==> a warning is generated for the well-setup project:

Incompatible .class files version in required binaries. Project '1.4' is targeting a 1.2 runtime, but is compiled against 'C:JavaSDKs/jdk1.4.2_30/jre/lib/rt.jar' (from the container 'JRE System Library [jdk1.4.2_30]') which requires a 1.4 runtime

This looks wrong/unexpected and we also don't show a warning in the project creation wizard or on the 'Java Compiler' properties page.


I guess this needs another round of investigation and discussion.
Comment 6 Markus Keller CLA 2012-10-16 12:02:49 EDT
Hmm, it looks like the implementation of JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL in in ClasspathEntry doesn't really solve the problems it was intended to solve (bug 36674). I think we should first fix the implementation problems and then reassess whether we can set it to "warning" by default (not for 3.8.2).

I don't think the current implementation is useful, and I would replace it. We could go the long way and deprecate the old option, add migration code, etc., but I would just declare the old thing as buggy and fix it. It's really not useful the way it currently is.

The option should just check whether the configured System Library on the classpath and the COMPILER_CODEGEN_TARGET_PLATFORM make sense:

- ClasspathEntry#validateLibraryEntry(..) should compare the versions with ==, not "libraryJDK > projectTargetJDK" (at least for Java versions >= 1.5; for 1.4 and below, some special treatment is probably necessary, since the class file version didn't always match the JDK version back then).

- ClasspathEntry#validateClasspathEntry(..) should not consider required projects. That's not what "incompatibleJDKLevel" is about.

- Javadoc of CORE_INCOMPATIBLE_JDK_LEVEL should tell about the fixed implementation.
Comment 7 Dani Megert CLA 2012-10-17 04:17:56 EDT
(In reply to comment #6)
> Hmm, it looks like the implementation of
> JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL in in ClasspathEntry doesn't really
> solve the problems it was intended to solve (bug 36674). I think we should
> first fix the implementation problems and then reassess whether we can set
> it to "warning" by default (not for 3.8.2).
> 
> I don't think the current implementation is useful, and I would replace it.
> We could go the long way and deprecate the old option, add migration code,
> etc., but I would just declare the old thing as buggy and fix it. It's
> really not useful the way it currently is.

+1 (we discussed this together yesterday).
Comment 8 Dani Megert CLA 2013-01-10 05:02:45 EST
Ping!
Comment 9 Srikanth Sankaran CLA 2013-01-11 01:48:57 EST
(In reply to comment #8)
> Ping!

Dani, what is the right priority for this, given Manoj (and others) are near
full time on Java 8 ?
Comment 10 Dani Megert CLA 2013-01-11 03:03:26 EST
(In reply to comment #9)
> (In reply to comment #8)
> > Ping!
> 
> Dani, what is the right priority for this, given Manoj (and others) are near
> full time on Java 8 ?

(In reply to comment #9)
> (In reply to comment #8)
> > Ping!
> 
> Dani, what is the right priority for this, given Manoj (and others) are near
> full time on Java 8 ?

I expect this fix to be quite simple (less than a day). Maybe this could be the first task for Shankha?

I'm pushing on this because currently people don't get a warning when working with 1.5 compliance and a 1.4 JRE (as an example) and it just happened again this week that code got released that later didn't compile.
Comment 11 Srikanth Sankaran CLA 2013-02-13 02:05:13 EST
Jay, please help take this forward, thanks.
Comment 12 Jay Arthanareeswaran CLA 2013-02-13 03:40:16 EST
Shankha, please go through comments. If you have any questions, we can discuss.

Let's target this for M6.
Comment 13 Srikanth Sankaran CLA 2013-03-07 22:38:01 EST
Jay, can you take this over - this needs to go in for M6.
Comment 14 Jay Arthanareeswaran CLA 2013-03-09 15:41:29 EST
(In reply to comment #6)
> - ClasspathEntry#validateLibraryEntry(..) should compare the versions with
> ==, not "libraryJDK > projectTargetJDK" (at least for Java versions >= 1.5;
> for 1.4 and below, some special treatment is probably necessary, since the
> class file version didn't always match the JDK version back then).

There is a problem with this - I find some of the jars part of the JRE libraries are compiled with an older version of JDK. Such libraries would get flagged too. Can we live with that?


> - ClasspathEntry#validateClasspathEntry(..) should not consider required
> projects. That's not what "incompatibleJDKLevel" is about.

Let's say project A (at JRE 1.4 level) depends on project B (at JRE 1.5 level) and project B has a JAR in it's classpath that was compiled with 1.5. If we remove that check, we would let some genuine error cases slip through, won't we?
Comment 15 Markus Keller CLA 2013-03-12 07:54:14 EDT
(In reply to comment #14)
Good points. JavaCore#CORE_INCOMPATIBLE_JDK_LEVEL in fact doesn't solve bug 36674, and it doesn't look like we have a good solution to make it fix that problem.

However, we already have org.eclipse.jdt.launching.JavaRuntime.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE, which is the right solution for bug 36674. And that one is already set to "warning" by default. Projects that use the recommended setup (EE on the classpath) already have enough support to detect the bad situation.

Closing this bug.
Comment 16 Jay Arthanareeswaran CLA 2013-03-12 08:41:17 EDT
Verified for 4.3 M6.