@@ -1204,9 +1204,11 @@ private void addMethodInvocation(SimpleName javaQualifier, List<?> arguments, IM
12041204 }
12051205 } else {
12061206 appendFinalMethodQualifier (expression , declaringClass , bname ,
1207- (isStatic && !isPrivate ? FINAL_ESCAPECACHE : FINAL_CACHE ));
1207+ (isStatic && !isPrivate ? FINAL_ESCAPECACHE : FINAL_CACHE )
1208+ | (isStatic ? FINAL_STATIC : 0 ));
12081209 buffer .append ("." );
12091210 }
1211+
12101212 // keep a pointer, because we may rewrite this
12111213 int ptLog = (doLog ? buffer .length () : 0 );
12121214
@@ -1247,10 +1249,11 @@ private void addMethodInvocation(SimpleName javaQualifier, List<?> arguments, IM
12471249
12481250 String j2sName = getFinalDotQualifiedNameForMethod (javaQualifier , mBinding ,
12491251 (expression == null ? METHOD_NULLEXPRESSION : 0 ) | METHOD_ISQUALIFIED
1250- | (lambdaArity >= 0 ? LAMBDA_METHOD : 0 ));
1252+ | (lambdaArity >= 0 ? LAMBDA_METHOD : 0 ) | ( isStatic ? FINAL_STATIC : 0 ) );
12511253
12521254 String finalMethodNameWith$Params = getFinalMethodNameWith$Params (j2sName , declaringClassJavaClassName ,
12531255 mBinding , null , true , METHOD_NOTSPECIAL );
1256+
12541257 if (lambdaArity >= 0 ) {
12551258 // The problem here is that we cannot apply a method from an interface
12561259 // because those methods are not present in JavaScript.
@@ -1323,8 +1326,12 @@ private void appendFinalMethodQualifier(Expression qualifier, ITypeBinding decla
13231326 }
13241327 } else if (qualifier instanceof Name && !isVariableBinding (qualifier )) {
13251328 buffer .append (getFinalJ2SClassNameQualifier ((Name ) qualifier , declaringClass , null , flags ));
1329+ } else if ((flags & FINAL_STATIC ) != 0 ) {
1330+ // ensure even if field.method(), as long as method is static, we use Class.method()
1331+ // otherwise a null value for field will throw an exception.
1332+ buffer .append (getFinalJ2SClassNameQualifier (null , declaringClass , null , flags ));
13261333 } else {
1327- // xxxx.field.foo()
1334+ // xxxx.field.foo() -- but only if foo is not static
13281335 // (x ? y : z).foo()
13291336 // xxx.this.foo()
13301337 qualifier .accept (this );
@@ -1593,7 +1600,7 @@ public boolean visit(WhileStatement node) {
15931600 private static final int FIELD_DECL_STATIC_NONDEFAULT = 1 ;
15941601 private static final int FIELD_DECL_STATIC_DEFAULTS = 2 ;
15951602 private static final int FIELD_DECL_NONSTATIC_ALL = 3 ;
1596-
1603+
15971604 private void addAnonymousFunctionWrapper (boolean isOpen ) {
15981605 buffer .append (
15991606 isOpen ? (buffer .lastIndexOf (")" ) >= buffer .length () - 3 ? ";" : "" ) + "\r \n (function(){" : "})()\r \n " );
@@ -4543,6 +4550,9 @@ private String getFinalNameForNode(SimpleName node, char lastBufferChar, IVariab
45434550
45444551 private static final int FINAL_LAMBDA = 32 ;
45454552
4553+ private static final int FINAL_STATIC = 64 ;
4554+
4555+
45464556 /**
45474557 * Provide access to C$.$clinit$ when a static method is called or a static
45484558 * field is accessed.
@@ -4565,9 +4575,9 @@ String getFinalJ2SClassNameQualifier(Name methodQualifier, ITypeBinding declarin
45654575
45664576 if (declaringJavaClassName == null )
45674577 declaringJavaClassName = getJavaClassNameQualified (declaringJavaClass );
4568- boolean doEscape = ((flags & FINAL_ESCAPE ) == FINAL_ESCAPE );
4578+ boolean isStatic = ((flags & FINAL_STATIC ) == FINAL_STATIC );
4579+ boolean doEscape = isStatic || ((flags & FINAL_ESCAPE ) == FINAL_ESCAPE );
45694580 boolean doCache = ((flags & FINAL_CACHE ) == FINAL_CACHE );
4570-
45714581 String name = removeBracketsAndFixNullPackageName (declaringJavaClassName );
45724582 doEscape &= !NameMapper .isClassKnown (name );
45734583 if (!doEscape ) {
@@ -4585,7 +4595,6 @@ String getFinalJ2SClassNameQualifier(Name methodQualifier, ITypeBinding declarin
45854595 // lambda classes will always be defined at this point. No need to cache them
45864596 if (name .indexOf ("$lambda" ) >= 0 )
45874597 return getFinalJ2SClassName (name , FINAL_P );
4588-
45894598 return getFinalClazzLoadI$Reference (declaringJavaClass , name , doCache );
45904599 }
45914600
0 commit comments