ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r1436748 - in /ant/core/trunk: ./ manual/Tasks/ src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/
Date Tue, 22 Jan 2013 05:04:00 GMT
Author: antoine
Date: Tue Jan 22 05:04:00 2013
New Revision: 1436748

URL: http://svn.apache.org/viewvc?rev=1436748&view=rev
Log:
PR 54090 Depend task does not handle invokeDynamic constant pool entries - java.lang.ClassFormatError:
Invalid Constant Pool entry Type 18

Added:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InvokeDynamicCPInfo.java
  (with props)
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodHandleCPInfo.java
      - copied, changed from r1436599, ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodRefCPInfo.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodTypeCPInfo.java
      - copied, changed from r1436599, ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/IntegerCPInfo.java
Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/manual/Tasks/depend.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1436748&r1=1436747&r2=1436748&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Jan 22 05:04:00 2013
@@ -69,6 +69,9 @@ Fixed bugs:
    MacOS X 10.7
    Bugzilla Report 52632
 
+ * Depend task does not handle invokeDynamic constant pool entries - java.lang.ClassFormatError:
Invalid Constant Pool entry Type 18
+   Bugzilla Report 54090
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/manual/Tasks/depend.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/manual/Tasks/depend.html?rev=1436748&r1=1436747&r2=1436748&view=diff
==============================================================================
--- ant/core/trunk/manual/Tasks/depend.html (original)
+++ ant/core/trunk/manual/Tasks/depend.html Tue Jan 22 05:04:00 2013
@@ -43,7 +43,7 @@ compiler. This is generally faster than 
 
 <p>
 To learn more about how this information is obtained from the class files, 
-please refer to <a href="http://java.sun.com/docs/books/jvms/">the Java 
+please refer to <a href="http://docs.oracle.com/javase/specs/">the Java
 Virtual Machine Specification</a>
 </p>
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java?rev=1436748&r1=1436747&r2=1436748&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java
Tue Jan 22 05:04:00 2013
@@ -62,6 +62,15 @@ public abstract class ConstantPoolEntry 
     /** Tag value for Name and Type entries. */
     public static final int CONSTANT_NAMEANDTYPE = 12;
 
+    /** Tag value for Method Handle entries */
+    public static final int CONSTANT_METHODHANDLE  = 15;
+
+    /** Tag value for Method Type entries */
+    public static final int CONSTANT_METHODTYPE = 16;
+
+    /** Tag value for InvokeDynamic entries*/
+    public static final int CONSTANT_INVOKEDYNAMIC = 18;
+
     /**
      * This entry's tag which identifies the type of this constant pool
      * entry.
@@ -155,6 +164,18 @@ public abstract class ConstantPoolEntry 
                 cpInfo = new NameAndTypeCPInfo();
 
                 break;
+            case CONSTANT_METHODHANDLE:
+                cpInfo = new MethodHandleCPInfo();
+
+                break;
+            case CONSTANT_METHODTYPE:
+                cpInfo = new MethodTypeCPInfo();
+
+                break;
+            case CONSTANT_INVOKEDYNAMIC:
+                cpInfo = new InvokeDynamicCPInfo();
+
+                break;
             default:
                 throw new ClassFormatError("Invalid Constant Pool entry Type "
                      + cpTag);

Added: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InvokeDynamicCPInfo.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InvokeDynamicCPInfo.java?rev=1436748&view=auto
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InvokeDynamicCPInfo.java
(added)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InvokeDynamicCPInfo.java
Tue Jan 22 05:04:00 2013
@@ -0,0 +1,85 @@
+/*
+ *  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.tools.ant.taskdefs.optional.depend.constantpool;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+/**
+ * An InvokeDynamic CP Info
+ *
+ */
+public class InvokeDynamicCPInfo extends ConstantCPInfo {
+
+    /** Index into the bootstrap methods for the class */
+    private int bootstrapMethodAttrIndex;
+    /** the value of the method descriptor pointed to */
+    private int nameAndTypeIndex;
+    /** the name and type CP info pointed to */
+    private NameAndTypeCPInfo nameAndTypeCPInfo;
+    /** */
+    /** Constructor.  */
+    public InvokeDynamicCPInfo() {
+        super(CONSTANT_INVOKEDYNAMIC, 1);
+    }
+
+    /**
+     * read a constant pool entry from a class stream.
+     *
+     * @param cpStream the DataInputStream which contains the constant pool
+     *      entry to be read.
+     * @exception java.io.IOException if there is a problem reading the entry from
+     *      the stream.
+     */
+    public void read(DataInputStream cpStream) throws IOException {
+        bootstrapMethodAttrIndex = cpStream.readUnsignedShort();
+        nameAndTypeIndex = cpStream.readUnsignedShort();
+    }
+
+    /**
+     * Print a readable version of the constant pool entry.
+     *
+     * @return the string representation of this constant pool entry.
+     */
+    public String toString() {
+        String value;
+        if (isResolved()) {
+            value = "Name = " + nameAndTypeCPInfo.getName() + ", type = " + nameAndTypeCPInfo.getType();
+        } else {
+            value = "BootstrapMethodAttrIndex inx = " + bootstrapMethodAttrIndex
+            + "NameAndType index = " + nameAndTypeIndex;
+        }
+
+        return value;
+    }
+    /**
+     * Resolve this constant pool entry with respect to its dependents in
+     * the constant pool.
+     *
+     * @param constantPool the constant pool of which this entry is a member
+     *      and against which this entry is to be resolved.
+     */
+    public void resolve(ConstantPool constantPool) {
+        nameAndTypeCPInfo
+                = (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex);
+        nameAndTypeCPInfo.resolve(constantPool);
+        super.resolve(constantPool);
+    }
+
+}
+

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/InvokeDynamicCPInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodHandleCPInfo.java
(from r1436599, ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodRefCPInfo.java)
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodHandleCPInfo.java?p2=ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodHandleCPInfo.java&p1=ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodRefCPInfo.java&r1=1436599&r2=1436748&rev=1436748&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodRefCPInfo.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodHandleCPInfo.java
Tue Jan 22 05:04:00 2013
@@ -21,27 +21,40 @@ import java.io.DataInputStream;
 import java.io.IOException;
 
 /**
- * A MethodRef CP Info
+ * A MethodHandle CP Info
  *
  */
-public class MethodRefCPInfo extends ConstantPoolEntry {
-    /** the name of the class defining this method */
-    private String methodClassName;
-    /** the name of the method */
-    private String methodName;
-    /** the method's type descriptor */
-    private String methodType;
-    /** The index into the constant pool which defines the class of this method. */
-    private int classIndex;
+public class MethodHandleCPInfo extends ConstantPoolEntry {
+    private ConstantPoolEntry reference;
+
+    /** reference kind **/
+    private ReferenceKind referenceKind;
+    /** Must be a valid index into the constant pool tabel. */
+    private int referenceIndex;
     /**
      * the index into the constant pool which defined the name and type
      * signature of the method
      */
     private int nameAndTypeIndex;
+    public enum ReferenceKind {
+        REF_getField(1),
+        REF_getStatic(2),
+        REF_putField(3),
+        REF_putStatic(4),
+        REF_invokeVirtual(5),
+        REF_invokeStatic(6),
+        REF_invokeSpecial(7),
+        REF_newInvokeSpecial(8),
+        REF_invokeInterface(9);
+        private final int referenceKind;
+        ReferenceKind(int referenceKind) {
+            this.referenceKind = referenceKind;
+        }
 
+    }
     /** Constructor. */
-    public MethodRefCPInfo() {
-        super(CONSTANT_METHODREF, 1);
+    public MethodHandleCPInfo() {
+        super(CONSTANT_METHODHANDLE, 1);
     }
 
     /**
@@ -49,12 +62,13 @@ public class MethodRefCPInfo extends Con
      *
      * @param cpStream the DataInputStream which contains the constant pool
      *      entry to be read.
-     * @exception IOException if there is a problem reading the entry from
+     * @exception java.io.IOException if there is a problem reading the entry from
      *      the stream.
      */
     public void read(DataInputStream cpStream) throws IOException {
-        classIndex = cpStream.readUnsignedShort();
-        nameAndTypeIndex = cpStream.readUnsignedShort();
+        referenceKind = ReferenceKind.values()[cpStream.readUnsignedByte() - 1];
+
+        referenceIndex = cpStream.readUnsignedShort();
     }
 
     /**
@@ -66,11 +80,10 @@ public class MethodRefCPInfo extends Con
         String value;
 
         if (isResolved()) {
-            value = "Method : Class = " + methodClassName + ", name = "
-                 + methodName + ", type = " + methodType;
+            value = "MethodHandle : " + reference.toString();
         } else {
-            value = "Method : Class index = " + classIndex
-                 + ", name and type index = " + nameAndTypeIndex;
+            value = "MethodHandle : Reference kind = " + referenceKind
+                 +  "Reference index = " + referenceIndex;
         }
 
         return value;
@@ -84,50 +97,11 @@ public class MethodRefCPInfo extends Con
      *      and against which this entry is to be resolved.
      */
     public void resolve(ConstantPool constantPool) {
-        ClassCPInfo methodClass
-             = (ClassCPInfo) constantPool.getEntry(classIndex);
-
-        methodClass.resolve(constantPool);
-
-        methodClassName = methodClass.getClassName();
-
-        NameAndTypeCPInfo nt
-             = (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex);
-
-        nt.resolve(constantPool);
-
-        methodName = nt.getName();
-        methodType = nt.getType();
-
+        reference = constantPool.getEntry(referenceIndex);
+        reference.resolve(constantPool);
         super.resolve(constantPool);
     }
 
-    /**
-     * Get the name of the class defining the method
-     *
-     * @return the name of the class defining this method
-     */
-    public String getMethodClassName() {
-        return methodClassName;
-    }
-
-    /**
-     * Get the name of the method.
-     *
-     * @return the name of the method.
-     */
-    public String getMethodName() {
-        return methodName;
-    }
-
-    /**
-     * Get the type signature of the method.
-     *
-     * @return the type signature of the method.
-     */
-    public String getMethodType() {
-        return methodType;
-    }
 
 }
 

Copied: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodTypeCPInfo.java
(from r1436599, ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/IntegerCPInfo.java)
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodTypeCPInfo.java?p2=ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodTypeCPInfo.java&p1=ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/IntegerCPInfo.java&r1=1436599&r2=1436748&rev=1436748&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/IntegerCPInfo.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/MethodTypeCPInfo.java
Tue Jan 22 05:04:00 2013
@@ -21,14 +21,18 @@ import java.io.DataInputStream;
 import java.io.IOException;
 
 /**
- * An Integer CP Info
+ * A Method Type CP Info
  *
  */
-public class IntegerCPInfo extends ConstantCPInfo {
+public class MethodTypeCPInfo extends ConstantCPInfo {
 
+    /** Index into the constant pool for the class */
+    private int methodDescriptorIndex;
+    /** the value of the method descriptor pointed to */
+    private String methodDescriptor;
     /** Constructor.  */
-    public IntegerCPInfo() {
-        super(CONSTANT_INTEGER, 1);
+    public MethodTypeCPInfo() {
+        super(CONSTANT_METHODTYPE, 1);
     }
 
     /**
@@ -36,20 +40,39 @@ public class IntegerCPInfo extends Const
      *
      * @param cpStream the DataInputStream which contains the constant pool
      *      entry to be read.
-     * @exception IOException if there is a problem reading the entry from
+     * @exception java.io.IOException if there is a problem reading the entry from
      *      the stream.
      */
     public void read(DataInputStream cpStream) throws IOException {
-        setValue(new Integer(cpStream.readInt()));
+        methodDescriptorIndex = cpStream.readUnsignedShort();
     }
 
     /**
+     * Resolve this constant pool entry with respect to its dependents in
+     * the constant pool.
+     *
+     * @param constantPool the constant pool of which this entry is a member
+     *      and against which this entry is to be resolved.
+     */
+    public void resolve(ConstantPool constantPool) {
+        Utf8CPInfo methodClass
+                = (Utf8CPInfo) constantPool.getEntry(methodDescriptorIndex);
+        methodClass.resolve(constantPool);
+        methodDescriptor = methodClass.getValue();
+        super.resolve(constantPool);
+    }
+    /**
      * Print a readable version of the constant pool entry.
      *
      * @return the string representation of this constant pool entry.
      */
     public String toString() {
-        return "Integer Constant Pool Entry: " + getValue();
+        if (! isResolved()) {
+            return "MethodDescriptorIndex: " + methodDescriptorIndex;
+        } else {
+            return "MethodDescriptor: " + methodDescriptor;
+
+        }
     }
 
 }



Mime
View raw message