Bug 43313

Summary: Strange javac behaviour when using javac from 1.3.1_09
Product: [Eclipse Project] JDT Reporter: Antoan Nikolaev <anikolaev>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: anikolaev
Version: 3.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
The file generated with the standard javac
none
File generated through eclipse none

Description Antoan Nikolaev CLA 2003-09-18 14:36:25 EDT
Dear Team,
We have been using Eclipse and we love it! Great job!
I am experiencing a very strange problem when compiling the same source 
file within eclipse and outside of it.
In both cases I am using Sun's JSDK 1.3.1_09.
Briefly this is what is going on:

class A implements java.io.Serializable {
   private final static SomeInterface var = SomeClass.getInstance("param");
   ...
   ...
}

When compiled through the eclipse ide the resulting
class would have code of the form ( I used pseudo code  in the above example)
class A implements java.io.Serialiazable {
    ...
    static Class class$0; /* synthetic field */

    static {
        class$0;
        if(class$0 != null) goto _L2; else goto _L1
_L1:
        JVM INSTR pop ;
        class$0 = Class.forName
("[Lcom.westernasset.atp.model.DealBaseTO;").getComponentType();
          goto _L2
        JVM INSTR new #148 <Class NoClassDefFoundError>;
        JVM INSTR dup_x1 ;
        JVM INSTR swap ;
        getMessage();
        NoClassDefFoundError();
        throw ;
_L2:
        WAMLogger.getInstance();
        CAT;
        status = STATUS_NEW;
        allocations = new HashMap();
}

}

when compiled outside of eclipse: 
class A implements java.io.Serializable {
   private final static SomeInterface var;
   ...
   ...
   static {
      var = SomeClass.getInstance("param");
   }
}

As you can see this produces two totaly diffrent classes
(the generation of the synthetic field in the first case) and
causes SerialVersionIDS to be different for both classes.

This wasn't the case with any of the previous releases of 1.3.1_09

Any ideas on how to run external javac and pass the same parameters to it?
JDT hides most of this now throught the common interface.

Best Regards,
Antoan Nikolaev,
Eclipse Fan!
Comment 1 Antoan Nikolaev CLA 2003-09-18 14:45:39 EDT
Created attachment 6156 [details]
The file generated with the standard javac

This is the file generated with the standard javac (1.3.1_09)
Comment 2 Antoan Nikolaev CLA 2003-09-18 14:46:18 EDT
Created attachment 6157 [details]
File generated through eclipse

this file is generated with eclipse, using 1.3.1_09
Comment 3 Philipe Mulet CLA 2003-09-19 05:26:42 EDT
Eclipse defines its own compiler implementation, which explains these 
inconsistencies. This is a known issue coming from the fact that these compiler 
internals are not specified, and neither compiler is right or wrong. They are 
just different.

Various evolutions of the same compiler also are affecting serialization as 
well. The only solution is to stick with one compiler version either Eclipse or 
javac. 

Also see bug 10104 and related ones.

*** This bug has been marked as a duplicate of 10104 ***
Comment 4 Philipe Mulet CLA 2003-09-19 05:29:14 EDT
Note that you can run the Eclipse compiler outside Eclipse through its Ant 
adapter, or as a command line tool:

http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt-core-
home/howto/batch%20compile/batchCompile.html