harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r642960 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200: ClassBands.java Segment.java bytecode/CPMethod.java
Date Mon, 31 Mar 2008 10:54:05 GMT
Author: sjanuary
Date: Mon Mar 31 03:53:52 2008
New Revision: 642960

URL: http://svn.apache.org/viewvc?rev=642960&view=rev
Log:
Fix for HARMONY-5654 ([classlib][pack200] Init methods cannot be synchronized)

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/Segment.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethod.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=642960&r1=642959&r2=642960&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
Mon Mar 31 03:53:52 2008
@@ -47,6 +47,8 @@
 
     private long[] classFlags;
 
+    private long[] classAccessFlags; // Access flags for writing to the class file
+
     private String[][] classInterfaces;
 
     private int[] classMethodCount;
@@ -77,11 +79,15 @@
 
     private long[][] fieldFlags;
 
+    private long[][] fieldAccessFlags;
+
     private ArrayList[][] methodAttributes;
 
     private String[][] methodDescr;
 
     private long[][] methodFlags;
+    
+    private long[][] methodAccessFlags;
 
     private final AttributeLayoutMap attrMap;
 
@@ -1203,10 +1209,27 @@
         return classFieldCount;
     }
 
-    public long[] getClassFlags() {
+    public long[] getRawClassFlags() {
         return classFlags;
     }
 
+    public long[] getClassFlags() throws Pack200Exception {
+    	if(classAccessFlags == null) {
+    		long mask = 0x7FFF;
+    		for (int i = 0; i < 16; i++) {
+				AttributeLayout layout = attrMap.getAttributeLayout(i, AttributeLayout.CONTEXT_CLASS);
+				if(layout != null && !layout.isDefaultLayout()) {
+					mask &= ~(1 << i);
+				}
+			}
+    		classAccessFlags = new long[classFlags.length];
+    		for (int i = 0; i < classFlags.length; i++) {
+    				classAccessFlags[i] = classFlags[i] & mask;
+    		}
+    	}
+        return classAccessFlags;
+    }
+
     public String[][] getClassInterfaces() {
         return classInterfaces;
     }
@@ -1239,8 +1262,24 @@
         return fieldDescr;
     }
 
-    public long[][] getFieldFlags() {
-        return fieldFlags;
+    public long[][] getFieldFlags() throws Pack200Exception {
+    	if(fieldAccessFlags == null) {
+    		long mask = 0x7FFF;
+    		for (int i = 0; i < 16; i++) {
+				AttributeLayout layout = attrMap.getAttributeLayout(i, AttributeLayout.CONTEXT_FIELD);
+				if(layout != null && !layout.isDefaultLayout()) {
+					mask &= ~(1 << i);
+				}
+			}
+    		fieldAccessFlags = new long[fieldFlags.length][];
+    		for (int i = 0; i < fieldFlags.length; i++) {
+    			fieldAccessFlags[i] = new long[fieldFlags[i].length];
+				for (int j = 0; j < fieldFlags[i].length; j++) {
+					fieldAccessFlags[i][j] = fieldFlags[i][j] & mask;
+				}
+    		}
+    	}
+        return fieldAccessFlags;
     }
 
     /**
@@ -1272,8 +1311,24 @@
         return methodDescr;
     }
 
-    public long[][] getMethodFlags() {
-        return methodFlags;
+    public long[][] getMethodFlags() throws Pack200Exception {
+    	if(methodAccessFlags == null) {
+    		long mask = 0x7FFF;
+    		for (int i = 0; i < 16; i++) {
+				AttributeLayout layout = attrMap.getAttributeLayout(i, AttributeLayout.CONTEXT_METHOD);
+				if(layout != null && !layout.isDefaultLayout()) {
+					mask &= ~(1 << i);
+				}
+			}
+    		methodAccessFlags = new long[methodFlags.length][];
+    		for (int i = 0; i < methodFlags.length; i++) {
+    			methodAccessFlags[i] = new long[methodFlags[i].length];
+				for (int j = 0; j < methodFlags[i].length; j++) {
+					methodAccessFlags[i][j] = methodFlags[i][j] & mask;
+				}
+    		}
+    	}
+        return methodAccessFlags;
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java?rev=642960&r1=642959&r2=642960&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
Mon Mar 31 03:53:52 2008
@@ -143,7 +143,7 @@
             AttributeLayout SOURCE_FILE = attrDefinitionBands.getAttributeDefinitionMap()
     				.getAttributeLayout(AttributeLayout.ATTRIBUTE_SOURCE_FILE,
     						AttributeLayout.CONTEXT_CLASS);
-    		if (SOURCE_FILE.matches(classBands.getClassFlags()[classNum])) {
+    		if (SOURCE_FILE.matches(classBands.getRawClassFlags()[classNum])) {
     		    int firstDollar = SegmentUtils.indexOfFirstDollar(fullName);
     		    String fileName = null;
 
@@ -202,13 +202,13 @@
 		}
 		// add methods
 		ClassFileEntry cfMethods[] = new ClassFileEntry[classBands.getClassMethodCount()[classNum]];
-		// fieldDescr and fieldFlags used to create this
+		// methodDescr and methodFlags used to create this
 		for (i = 0; i < cfMethods.length; i++) {
             String descriptorStr = classBands.getMethodDescr()[classNum][i];
             int colon = descriptorStr.indexOf(':');
             CPUTF8 name = cpBands.cpUTF8Value(descriptorStr.substring(0,colon), ClassConstantPool.DOMAIN_NORMALASCIIZ);
             CPUTF8 descriptor = cpBands.cpUTF8Value(descriptorStr.substring(colon+1), ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
-			cfMethods[i] = cp.add(new CPMethod(name, descriptor, classBands
+            cfMethods[i] = cp.add(new CPMethod(name, descriptor, classBands
                     .getMethodFlags()[classNum][i], classBands
                     .getMethodAttributes()[classNum][i]));
 		}

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethod.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethod.java?rev=642960&r1=642959&r2=642960&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethod.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/CPMethod.java
Mon Mar 31 03:53:52 2008
@@ -21,8 +21,7 @@
 public class CPMethod extends CPMember {
 
 	public CPMethod(CPUTF8 name, CPUTF8 descriptor, long flags, List attributes) {
-		// TODO Check that we only pass these on, or remap
-		super(name, descriptor, 0x7FFF & flags, attributes);
+		super(name, descriptor, flags, attributes);
 	}
 
 }



Mime
View raw message