@@ -1737,18 +1737,23 @@ private IVariableBinding getLeftVariableBinding(Expression left, IBinding leftTy
17371737 }
17381738
17391739 /**
1740- * Proved access to C$.$clinit$ when a static method is called or a static field is accessed.
1740+ * Proved access to C$.$clinit$ when a static method is called or a static
1741+ * field is accessed.
17411742 *
17421743 * @param methodQualifier
17431744 * SimpleName qualifier in qualifier.methodName()
17441745 * @param className
1745- * @param doEscape set true except for static nonprivate field names
1746- * @param doCache generally true, but not for initial class definitions or for some nonstatic references
1747- * @param doAppend true to use buffer.append;
1748- * @return name wrapped if necessary by nested Class.load() calls
1746+ * @param doEscape
1747+ * set true except for static nonprivate field names
1748+ * @param doCache
1749+ * generally true, but not for initial class definitions or for
1750+ * some nonstatic references
1751+ * @param doAppend
1752+ * true to use buffer.append;
1753+ * @return name wrapped if necessary by nested Class.load() calls
17491754 */
1750- protected String getQualifiedStaticName (Name methodQualifier , String className , boolean doEscape ,
1751- boolean doCache , boolean doAppend ) {
1755+ protected String getQualifiedStaticName (Name methodQualifier , String className , boolean doEscape , boolean doCache ,
1756+ boolean doAppend ) {
17521757 // BH: The idea here is to load these on demand.
17531758 // It will require synchronous loading,
17541759 // but it will ensure that a class is only
@@ -1759,7 +1764,7 @@ protected String getQualifiedStaticName(Name methodQualifier, String className,
17591764 if (!doEscape ) {
17601765 if (methodQualifier != null ) {
17611766 methodQualifier .accept (this );
1762- return null ;
1767+ return null ;
17631768 }
17641769 s = className ;
17651770 doCache = false ;
@@ -1774,38 +1779,37 @@ protected String getQualifiedStaticName(Name methodQualifier, String className,
17741779 if (s == null ) {
17751780 if (methodQualifier != null )
17761781 className = fixNameNoC$ (null , className );
1777- s = "Clazz.load(" ;
1778- String [] parts = className .split ("\\ ." );
1779- int nclass = 0 ;
1780- for (int i = 0 ; i < parts .length ; i ++) {
1781- String part = parts [i ];
1782- if (i == 0 ) {
1783- if (part .equals ("C$" )) {
1784- s += part ;
1785- continue ;
1786- }
1787- if (part .equals ("P$" )) {
1788- // can't do this with Clazz.load
1789- part = getPackageName ();
1790- }
1791- }
1792- s += (i == 0 ? "'" : "." );
1793- s += part ;
1794- if (Character .isUpperCase (part .charAt (0 ))) {
1795- if (nclass > 0 )
1796- s = "Clazz.load(" + s ;
1797- if (++nclass == 1 && s .indexOf ("'" ) >= 0 )
1798- s += "'" ;
1799- s += ")" ;
1800- }
1801- }
1782+ s = getNestedClazzLoads (className );
18021783 if (n != null )
18031784 s = "(I$[" + n + "] || (I$[" + n + "]=" + s + "))" ;
18041785 }
18051786 if (doAppend )
18061787 buffer .append (s );
18071788 return s ;
1789+ }
18081790
1791+ /**
1792+ * Nest loads of inner classes pkg.Foo.Bar as Clazz.load(Clazz.load('pkg.Foo').Bar)
1793+ *
1794+ * @param className
1795+ * @return
1796+ */
1797+ private String getNestedClazzLoads (String className ) {
1798+ String [] parts = className .split ("\\ ." );
1799+ String s = parts [0 ];
1800+ if (s .equals ("P$" )) {
1801+ // can't do this with Clazz.load
1802+ s = getPackageName ();
1803+ }
1804+ int i = 1 ;
1805+ // loop through packages and outer Class
1806+ while (i < parts .length && (i == 1 || !Character .isUpperCase (parts [i - 1 ].charAt (0 ))))
1807+ s += "." + parts [i ++];
1808+ String ret = "Clazz.load('" + s + "')" ;
1809+ // add inner classes
1810+ while (i < parts .length )
1811+ ret += "Clazz.load(" + ret + "." + parts [i ++] + ")" ;
1812+ return ret ;
18091813 }
18101814
18111815 private boolean haveDirectStaticAccess (Expression exp ) {
0 commit comments