harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r750481 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200: ClassBands.java IcBands.java
Date Thu, 05 Mar 2009 15:55:30 GMT
Author: sjanuary
Date: Thu Mar  5 15:55:28 2009
New Revision: 750481

URL: http://svn.apache.org/viewvc?rev=750481&view=rev
Log:
Pack200 - minor fixes for inner class attributes

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java?rev=750481&r1=750480&r2=750481&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
Thu Mar  5 15:55:28 2009
@@ -183,7 +183,7 @@
     public void currentClassReferencesInnerClass(CPClass inner) {
         if(!(index >= class_this.length)) {
             CPClass currentClass = class_this[index];
-            if(currentClass != null && !currentClass.equals(inner) && !isInnerClassOf(currentClass,
inner)) {
+            if(currentClass != null && !currentClass.equals(inner) && !isInnerClassOf(currentClass.toString(),
inner)) {
                 Set referencedInnerClasses = (Set)classReferencesInnerClass.get(currentClass);
                 if(referencedInnerClasses == null) {
                     referencedInnerClasses = new HashSet();
@@ -194,15 +194,22 @@
         }
     }
 
-    private boolean isInnerClassOf(CPClass possibleInner, CPClass possibleOuter) {
-        String currentClassName = possibleInner.toString();
-        if(possibleInner.isInnerClass()) {
-            String superClassName = currentClassName.substring(0, currentClassName.lastIndexOf('$'));
-            return superClassName.equals(possibleOuter.toString());
+    private boolean isInnerClassOf(String possibleInner, CPClass possibleOuter) {
+        if(isInnerClass(possibleInner)) {
+            String superClassName = possibleInner.substring(0, possibleInner.lastIndexOf('$'));
+            if(superClassName.equals(possibleOuter.toString())) {
+                return true;
+            } else { // do this recursively
+                return isInnerClassOf(superClassName, possibleOuter);
+            }
         }
         return false;
     }
 
+    private boolean isInnerClass(String possibleInner) {
+        return possibleInner.indexOf('$') != -1;
+    }
+
     public void addField(int flags, String name, String desc, String signature,
             Object value) {
         flags = flags & 0xFFFF;
@@ -292,7 +299,7 @@
                         .hasNext();) {
                     CPClass inner = (CPClass) iterator2.next();
                     IcTuple icTuple = segment.getIcBands().getIcTuple(inner);
-                    if(icTuple != null) {
+                    if(icTuple != null && ! icTuple.isAnonymous()) {
                         // should transmit an icLocal entry
                         icLocal.add(icTuple);
                         innerN++;

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java?rev=750481&r1=750480&r2=750481&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
Thu Mar  5 15:55:28 2009
@@ -156,6 +156,12 @@
             return C.compareTo(((IcTuple)arg0).C);
         }
 
+        public boolean isAnonymous() {
+            String className = C.toString();
+            String innerName = className.substring(className.lastIndexOf('$') + 1);
+            return Character.isDigit(innerName.charAt(0));
+        }
+
     }
 
     public IcTuple getIcTuple(CPClass inner) {



Mime
View raw message