You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sj...@apache.org on 2008/03/06 15:48:56 UTC

svn commit: r634282 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200: ClassBands.java bytecode/DeprecatedAttribute.java

Author: sjanuary
Date: Thu Mar  6 06:48:55 2008
New Revision: 634282

URL: http://svn.apache.org/viewvc?rev=634282&view=rev
Log:
Fix for HARMONY-5571 ([classlib][pack200] Deprecated method attribute not being preserved)

Added:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/DeprecatedAttribute.java   (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.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=634282&r1=634281&r2=634282&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  6 06:48:55 2008
@@ -34,6 +34,7 @@
 import org.apache.harmony.pack200.bytecode.ClassConstantPool;
 import org.apache.harmony.pack200.bytecode.ClassFileEntry;
 import org.apache.harmony.pack200.bytecode.ConstantValueAttribute;
+import org.apache.harmony.pack200.bytecode.DeprecatedAttribute;
 import org.apache.harmony.pack200.bytecode.EnclosingMethodAttribute;
 import org.apache.harmony.pack200.bytecode.ExceptionsAttribute;
 import org.apache.harmony.pack200.bytecode.LineNumberTableAttribute;
@@ -220,9 +221,16 @@
             }
         }
 
+        AttributeLayout deprecatedLayout = attrMap.getAttributeLayout(
+                AttributeLayout.ATTRIBUTE_DEPRECATED,
+                AttributeLayout.CONTEXT_FIELD);
+
         for (int i = 0; i < classCount; i++) {
             for (int j = 0; j < fieldFlags[i].length; j++) {
                 long flag = fieldFlags[i][j];
+                if(deprecatedLayout.matches(flag)) {
+                    fieldAttributes[i][j].add(new DeprecatedAttribute());
+                }
                 if (constantValueLayout.matches(flag)) {
                     // we've got a value to read
                     long result = field_constantValue_KQ[constantValueIndex];
@@ -357,12 +365,19 @@
             }
         }
 
+        AttributeLayout deprecatedLayout = attrMap.getAttributeLayout(
+                AttributeLayout.ATTRIBUTE_DEPRECATED,
+                AttributeLayout.CONTEXT_METHOD);
+
         // Add attributes to the attribute arrays
         int methodExceptionsIndex = 0;
         int methodSignatureIndex = 0;
         for (int i = 0; i < methodAttributes.length; i++) {
             for (int j = 0; j < methodAttributes[i].length; j++) {
                 long flag = methodFlags[i][j];
+                if(deprecatedLayout.matches(flag)) {
+                    methodAttributes[i][j].add(new DeprecatedAttribute());
+                }
                 if (methodExceptionsLayout.matches(flag)) {
                     int n = numExceptions[methodExceptionsIndex];
                     String[] exceptions = methodExceptionsRS[methodExceptionsIndex];
@@ -451,6 +466,10 @@
         int[] classAttrCalls = decodeBandInt("class_attr_calls", in,
                 Codec.UNSIGNED5, callCount);
 
+        AttributeLayout deprecatedLayout = attrMap.getAttributeLayout(
+                AttributeLayout.ATTRIBUTE_DEPRECATED,
+                AttributeLayout.CONTEXT_CLASS);
+
         AttributeLayout sourceFileLayout = attrMap.getAttributeLayout(
                 AttributeLayout.ATTRIBUTE_SOURCE_FILE,
                 AttributeLayout.CONTEXT_CLASS);
@@ -558,7 +577,9 @@
         icLocal = new IcTuple[classCount][];
         for (int i = 0; i < classCount; i++) {
             long flag = classFlags[i];
-
+            if(deprecatedLayout.matches(classFlags[i])) {
+                classAttributes[i].add(new DeprecatedAttribute());
+            }
             if (sourceFileLayout.matches(flag)) {
                 long result = classSourceFile[sourceFileIndex];
                 String value = (String) sourceFileLayout.getValue(result,

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/DeprecatedAttribute.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/DeprecatedAttribute.java?rev=634282&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/DeprecatedAttribute.java (added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/DeprecatedAttribute.java Thu Mar  6 06:48:55 2008
@@ -0,0 +1,51 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.pack200.bytecode;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+public class DeprecatedAttribute extends Attribute {
+
+    private static final CPUTF8 attributeName = new CPUTF8("Deprecated", ClassConstantPool.DOMAIN_ATTRIBUTEASCIIZ);
+
+    public DeprecatedAttribute() {
+        super(attributeName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.bytecode.Attribute#getLength()
+     */
+    protected int getLength() {
+        return 0;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.bytecode.Attribute#writeBody(java.io.DataOutputStream)
+     */
+    protected void writeBody(DataOutputStream dos) throws IOException {
+        // No body
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.harmony.pack200.bytecode.ClassFileEntry#toString()
+     */
+    public String toString() {
+        return "Deprecated Attribute";
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/DeprecatedAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/bytecode/DeprecatedAttribute.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain