Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Eclipse or Oracle Java compiler disagreement(Code that compiled in both, but no longer compiles in Eclipse Oxygen)
Eclipse or Oracle Java compiler disagreement [message #1782366] Thu, 22 February 2018 11:58 Go to next message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 149
Registered: March 2010
Senior Member
Hi,

I upgraded to Eclipse Oxygen yesterday and as soon as I fired up my workspace JDT complained about some code in it. That code compiles fine with Eclipse Neon (JDT 3.12.3) and Oracle Java 8 JDK. I also upgraded my Oracle JDK to 8 update 161 (latest Java 8 version) and it still seems to think that there are no issues with the code that Oxygen is offended by.

I was about to file a bug report and trimmed the it down to this snippet which reproduces the problem:

package playground;

public class EclipseOxygen
{
    public <T, E extends T> EclipseOxygen(E impl, Class<T> intf) {
    }
    public <T, E extends T> void andAsMethod(E impl, Class<T> intf) {
    }
    
    public <T> void something(T ref) {
        @SuppressWarnings("unchecked")
        Class<? super T> clazz = (Class<? super T>) ref.getClass();
        new EclipseOxygen(ref, clazz.asSubclass(EclipseOxygen.class));
        andAsMethod(ref, clazz.asSubclass(EclipseOxygen.class));
    }
}


Oxygen cries foul when invoking the constructor:

The constructor EclipseOxygen(T,Class<capture#4-of ? extends EclipseOxygen) is undefined


Same error two lines below in the method invocation.

The snippet though made it apparent to me that T is obviously unrelated (in terms of bounds) to class EclipseOxygen so it seems to me that Oxygen's JDT is actually right? I fixed it with casting ref to that class:

package playground;

public class EclipseOxygen
{
    public <T, E extends T> EclipseOxygen(E impl, Class<T> intf) {        
    }
    public <T, E extends T> void andAsMethod(E impl, Class<T> intf) {   
    }
    
    public <T> void something(T ref) {
        @SuppressWarnings("unchecked")
        Class<? super T> clazz = (Class<? super T>) ref.getClass();
        new EclipseOxygen((EclipseOxygen)ref, clazz.asSubclass(EclipseOxygen.class));
        andAsMethod((EclipseOxygen)ref, clazz.asSubclass(EclipseOxygen.class));
    }
}


It seems that the Class<? super T> confuses Eclipse Neon and Oracle JDK and this is a bug in both (now fixed in Oxygen)?


Re: Eclipse or Oracle Java compiler disagreement [message #1784912 is a reply to message #1782366] Thu, 05 April 2018 15:48 Go to previous message
Patrick Gold is currently offline Patrick GoldFriend
Messages: 1
Registered: April 2018
Junior Member
I am seeing a similar issue. After updating Eclipse it won't compile classes based on org.apache.thrift.TProcessor.

I switched back to a working branch that hasn't been modified in a while and the new Eclipse still fails with the compilation of this class.

Please advise.
Previous Topic:Eclipse compatibility with Java updates
Next Topic:eclipse.jdt.core compilation on Ubuntu command line
Goto Forum:
  


Current Time: Fri Apr 26 10:23:20 GMT 2024

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

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

Back to the top