Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Eclipse 3.4.1 java compiler creating class file with references to missing classes
Eclipse 3.4.1 java compiler creating class file with references to missing classes [message #257599] Tue, 25 November 2008 07:50 Go to next message
Eclipse UserFriend
My testproject to reproduce this behaviour consists of a new java
project with a single class. The following Java source contains two
errors. The import to "somepackage" cannot be resolved and "SomeClass"
cannot be resolved to a type. That's correct, as the package and the
class are not available. The problem is the Test.class that Eclipse
generates from this source.

This is the source (Test.java):
package com.test;
import somepackage.SomeClass;
public class Test implements SomeClass {}

And this is the generated Test.class using Eclipse 3.4.1 (Ganymede) and
then decompiling it with Jad v1.5.8g:

package com.test;
import SomeClass;
public class Test implements SomeClass{
public Test(){
throw new Error("Unresolved compilation problems: \n\tThe import
somepackage cannot be resolved\n\tSomeClass cannot be resolved to a
type\n");
}
}

As you see, the import of the classname is still there (only the
packagename was removed) and the reference to the class SomeClass is
also still there! The Error text in the constructor was created
correctly, but the references are not removed.

Older versions of Eclipse (used Eclipse 3.3.1.1 Europa before) generated
a class file with all unresolved references removed:

package com.test;
public class Test{
public Test(){
throw new Error("Unresolved compilation problems: \n\tThe
import somepackage cannot be resolved\n\tSomeClass cannot be resolved to
a type\n");
}
}

I would like to have this behaviour back. I checked the compiler
preferences but couldn't find anything that was different in the
settings. There are no errors in the log file. Both Eclipse versions run
with the JDK1.6_10. Does anyone know why Eclipse 3.4.1 (detailed version
below) generates class files that still contain references to
unavailable classes and how to fix this?


Eclipse Platform
Version: 3.4.1.r341_v20080731-9I96EiDElYevwz-p1bP5z-NlAaP7vtX6Utotqsu
Build id: M20080911-1700

Never change a running system ;)

Many thanks,
Heiko
Re: Eclipse 3.4.1 java compiler creating class file with references to missing classes [message #257604 is a reply to message #257599] Tue, 25 November 2008 09:13 Go to previous messageGo to next message
Eclipse UserFriend
Heiko Minning a écrit :
> This is the source (Test.java):
> package com.test;
> import somepackage.SomeClass;
> public class Test implements SomeClass {}
>
> And this is the generated Test.class using Eclipse 3.4.1 (Ganymede) and
> then decompiling it with Jad v1.5.8g:
>
> package com.test;
> import SomeClass;
> public class Test implements SomeClass{
> public Test(){
> throw new Error("Unresolved compilation problems: \n\tThe
> import somepackage cannot be resolved\n\tSomeClass cannot be resolved to
> a type\n");
> }
> }
>
> As you see, the import of the classname is still there (only the
> packagename was removed) and the reference to the class SomeClass is
> also still there! The Error text in the constructor was created
> correctly, but the references are not removed.
I believe this comes from the missing type support added for 3.4. Please
open a bug report against JDT/Core with steps to reproduce and explain
why the old behavior is better.
--
Olivier
Re: Eclipse 3.4.1 java compiler creating class file with references to missing classes [message #257618 is a reply to message #257604] Wed, 26 November 2008 10:16 Go to previous message
Eclipse UserFriend
Olivier Thomann schrieb:
> Heiko Minning a écrit :
>> This is the source (Test.java):
>> package com.test;
>> import somepackage.SomeClass;
>> public class Test implements SomeClass {}
>>
>> And this is the generated Test.class using Eclipse 3.4.1 (Ganymede)
>> and then decompiling it with Jad v1.5.8g:
>>
>> package com.test;
>> import SomeClass;
>> public class Test implements SomeClass{
>> public Test(){
>> throw new Error("Unresolved compilation problems: \n\tThe
>> import somepackage cannot be resolved\n\tSomeClass cannot be resolved
>> to a type\n");
>> }
>> }
>>
>> As you see, the import of the classname is still there (only the
>> packagename was removed) and the reference to the class SomeClass is
>> also still there! The Error text in the constructor was created
>> correctly, but the references are not removed.
> I believe this comes from the missing type support added for 3.4. Please
> open a bug report against JDT/Core with steps to reproduce and explain
> why the old behavior is better.
> --
> Olivier


Done:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256443

If anyone else needs this changed please comment on the bug.
Previous Topic:Dead code detection
Next Topic:Supressing some packages in the PackageSelectionDialog
Goto Forum:
  


Current Time: Tue Apr 29 06:31:49 EDT 2025

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

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

Back to the top