@@ -1284,8 +1284,6 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
12841284 trailingBuffer = new TrailingBuffer ();
12851285 }
12861286
1287- boolean hasSuperclass = hasSuperClass (binding );
1288-
12891287 for (Iterator <?> iter = bodyDeclarations .iterator (); iter .hasNext ();) {
12901288 BodyDeclaration element = (BodyDeclaration ) iter .next ();
12911289 boolean isField = element instanceof FieldDeclaration ;
@@ -1301,8 +1299,9 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
13011299 if (isField || element instanceof Initializer ) {
13021300 if ((isInterface || isStatic (element )) && !checkj2sIgnore (element )) {
13031301 lstStatic .add (element );
1304- if (isField && hasSuperclass )
1302+ if (isField )
13051303 addFieldDeclaration ((FieldDeclaration ) element , FIELD_DECL_STATIC_DEFAULTS );
1304+
13061305 }
13071306 } else if (!havePrivateMethods && element instanceof MethodDeclaration ) {
13081307 if (Modifier .isPrivate (((MethodDeclaration ) element ).resolveBinding ().getModifiers ())) {
@@ -1313,18 +1312,17 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
13131312 }
13141313 if (lstStatic .size () > 0 || hasDependents ) {
13151314 pt = buffer .length ();
1316- buffer .append ("\r \n C$.$clinit$ = function() {Clazz.load(C$, 1);\r \n " );
13171315 boolean haveDeclarations = false ;
1316+ buffer .append ("\r \n C$.$clinit$ = function() {Clazz.load(C$, 1);\r \n " );
13181317 for (int i = lstStatic .size (); --i >= 0 ;) {
13191318 BodyDeclaration element = lstStatic .remove (0 );
13201319 if (element instanceof Initializer ) {
13211320 element .accept (this );
13221321 buffer .append (";\r \n " );
13231322 haveDeclarations = true ;
1324- continue ;
1325- }
1326- if (addFieldDeclaration ((FieldDeclaration ) element , FIELD_DECL_STATIC_NONDEFAULT ))
1323+ } else if (addFieldDeclaration ((FieldDeclaration ) element , FIELD_DECL_STATIC_NONDEFAULT )) {
13271324 haveDeclarations = true ;
1325+ }
13281326 }
13291327 if (haveDeclarations || hasDependents )
13301328 buffer .append ("}\r \n " );
@@ -1542,18 +1540,19 @@ private boolean addFieldDeclaration(FieldDeclaration field, int mode) {
15421540 for (Iterator <?> iter = fragments .iterator (); iter .hasNext ();) {
15431541 VariableDeclarationFragment fragment = (VariableDeclarationFragment ) iter .next ();
15441542 Expression initializer = fragment .getInitializer ();
1545- if (isFinal && VariableAdapter .getConstantValue (initializer ) != null )
1543+ if (isFinal ? VariableAdapter .getConstantValue (initializer ) != null
1544+ : isStatic && initializer == null && !needDefault )
15461545 continue ;
15471546 int len = buffer .length ();
15481547 String prefix = (isStatic ? "C$." : "this." )
15491548 + getCheckedFieldName (J2SMapAdapter .getJ2SName (fragment .getName ()), classBinding , false );
15501549 buffer .append (prefix );
15511550 buffer .append (" = " );
15521551 int len1 = buffer .length ();
1552+
15531553 if (initializer == null || needDefault ) {
15541554 // Route default for this to the $init0$ buffer if nonstatic, or straight to the class if static
1555- // if static and not initialized or nonstatic and there is a
1556- // superclass
1555+ // if static and not initialized
15571556
15581557 buffer .append (code == null ? "null" : getPrimitiveDefault (code ));
15591558 buffer .append (";\r \n " );
0 commit comments