@@ -252,6 +252,7 @@ private void buildAll() {
252252 if (DEBUG && this .lastState != null )
253253 System .out .println ("JavaBuilder: Clearing last state : " + this .lastState ); //$NON-NLS-1$
254254 clearLastState ();
255+ // j2sChange: Instead of BatchImageBuilder use Java2ScriptBatchImageBuilder
255256 BatchImageBuilder imageBuilder = new Java2ScriptBatchImageBuilder (this , true );
256257 imageBuilder .build ();
257258 recordNewState (imageBuilder .newState );
@@ -263,6 +264,7 @@ private void buildDeltas(SimpleLookupTable deltas) {
263264 if (DEBUG && this .lastState != null )
264265 System .out .println ("JavaBuilder: Clearing last state : " + this .lastState ); //$NON-NLS-1$
265266 clearLastState (); // clear the previously built state so if the build fails, a full build will occur next time
267+ // j2sChange: Instead of IncrementalImageBuilder use Java2ScriptIncrementalImageBuilder.
266268 IncrementalImageBuilder imageBuilder = new Java2ScriptIncrementalImageBuilder (this );
267269 if (imageBuilder .build (deltas )) {
268270 recordNewState (imageBuilder .newState );
@@ -419,7 +421,18 @@ private SimpleLookupTable findDeltas() {
419421}
420422
421423public State getLastState (IProject project ) {
424+ // j2sChange: We need to convert the "Eclipse" State to the "Java2Script" State.
422425 org .eclipse .jdt .internal .core .builder .State lastBuiltState = (org .eclipse .jdt .internal .core .builder .State ) JavaModelManager .getJavaModelManager ().getLastBuiltState (project , this .notifier .monitor );
426+ return toJava2ScriptState (project , lastBuiltState );
427+ }
428+
429+ // j2sChange: convert an "Eclipse" State to a "Java2Script" State.
430+ private State toJava2ScriptState (IProject project , org .eclipse .jdt .internal .core .builder .State lastBuiltState ) {
431+ // We use 'instance to bytes' serialization and 'bytes to instance' deserialization
432+ // to do the conversions.
433+ //
434+ // (Note: casting is not an option here, as both State classes are independent.).
435+
423436 if (lastBuiltState == null ) {
424437 return null ;
425438 }
@@ -785,6 +798,20 @@ private void recordNewState(State state) {
785798 if (prereqProject != null && prereqProject != this .currentProject )
786799 state .recordStructuralDependency (prereqProject , getLastState (prereqProject ));
787800 }
801+ if (DEBUG )
802+ System .out .println ("JavaBuilder: Recording new state : " + state ); //$NON-NLS-1$
803+ // state.dump();
804+
805+ // j2sChange: We need to convert the "Java2Script" State to the "Eclipse" State.
806+ JavaModelManager .getJavaModelManager ().setLastBuiltState (this .currentProject , toEclipseState (state ));
807+ }
808+
809+ // j2sChange: convert a "Java2Script" State to an "Eclipse" State.
810+ private org .eclipse .jdt .internal .core .builder .State toEclipseState (State state ) {
811+ // We use 'instance to bytes' serialization and 'bytes to instance' deserialization
812+ // to do the conversions.
813+ //
814+ // (Note: casting is not an option here, as both State classes are independent.).
788815
789816 ByteArrayOutputStream baos = new ByteArrayOutputStream ();
790817 DataOutputStream out = new DataOutputStream (baos );
@@ -802,11 +829,7 @@ private void recordNewState(State state) {
802829 } catch (IOException e ) {
803830 e .printStackTrace ();
804831 }
805-
806- if (DEBUG )
807- System .out .println ("JavaBuilder: Recording new state : " + state ); //$NON-NLS-1$
808- // state.dump();
809- JavaModelManager .getJavaModelManager ().setLastBuiltState (this .currentProject , newState );
832+ return newState ;
810833}
811834
812835/**
0 commit comments