commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject svn commit: r1551450 - /commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/
Date Tue, 17 Dec 2013 02:51:54 GMT
Author: dbrosius
Date: Tue Dec 17 02:51:54 2013
New Revision: 1551450

URL: http://svn.apache.org/r1551450
Log:
more invoke dynamic implementation, split out from FieldOrMethod as not truly a subclass -
patch by Bill Pugh reviewed by dbrosius

Added:
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/NameSignatureInstruction.java
Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/EmptyVisitor.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldOrMethod.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GETFIELD.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GETSTATIC.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEINTERFACE.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKESPECIAL.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKESTATIC.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEVIRTUAL.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/PUTFIELD.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/PUTSTATIC.java
    commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/VisitorSupportsInvokeDynamic.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/EmptyVisitor.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/EmptyVisitor.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/EmptyVisitor.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/EmptyVisitor.java Tue
Dec 17 02:51:54 2013
@@ -744,7 +744,9 @@ public abstract class EmptyVisitor imple
     public void visitBREAKPOINT( BREAKPOINT obj ) {
     }
 
-
+    public void visitNameSignatureInstruction(NameSignatureInstruction obj) {
+	}
+    
 	public void visitINVOKEDYNAMIC(INVOKEDYNAMIC obj) {
 	}
 }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldOrMethod.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldOrMethod.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldOrMethod.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/FieldOrMethod.java Tue
Dec 17 02:51:54 2013
@@ -18,9 +18,7 @@
 package org.apache.bcel.generic;
 
 import org.apache.bcel.classfile.ConstantCP;
-import org.apache.bcel.classfile.ConstantNameAndType;
 import org.apache.bcel.classfile.ConstantPool;
-import org.apache.bcel.classfile.ConstantUtf8;
 
 /**
  * Super class for InvokeInstruction and FieldInstruction, since they have
@@ -29,7 +27,7 @@ import org.apache.bcel.classfile.Constan
  * @version $Id$
  * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
  */
-public abstract class FieldOrMethod extends CPInstruction implements LoadClass {
+public abstract class FieldOrMethod extends NameSignatureInstruction implements LoadClass
{
 
     private static final long serialVersionUID = 2036985877748835708L;
 
@@ -50,26 +48,6 @@ public abstract class FieldOrMethod exte
     }
 
 
-    /** @return signature of referenced method/field.
-     */
-    public String getSignature( ConstantPoolGen cpg ) {
-        ConstantPool cp = cpg.getConstantPool();
-        ConstantCP cmr = (ConstantCP) cp.getConstant(index);
-        ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
-        return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes();
-    }
-
-
-    /** @return name of referenced method/field.
-     */
-    public String getName( ConstantPoolGen cpg ) {
-        ConstantPool cp = cpg.getConstantPool();
-        ConstantCP cmr = (ConstantCP) cp.getConstant(index);
-        ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
-        return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
-    }
-
-
     /** @return name of the referenced class/interface
      *  @deprecated If the instruction references an array class,
      *    this method will return "java.lang.Object".

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GETFIELD.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GETFIELD.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GETFIELD.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GETFIELD.java Tue Dec
17 02:51:54 2013
@@ -80,6 +80,8 @@ public class GETFIELD extends FieldInstr
         v.visitTypedInstruction(this);
         v.visitLoadClass(this);
         v.visitCPInstruction(this);
+        if (v instanceof VisitorSupportsInvokeDynamic) 
+            ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this);
         v.visitFieldOrMethod(this);
         v.visitFieldInstruction(this);
         v.visitGETFIELD(this);

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GETSTATIC.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GETSTATIC.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GETSTATIC.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/GETSTATIC.java Tue Dec
17 02:51:54 2013
@@ -78,6 +78,8 @@ public class GETSTATIC extends FieldInst
         v.visitTypedInstruction(this);
         v.visitLoadClass(this);
         v.visitCPInstruction(this);
+        if (v instanceof VisitorSupportsInvokeDynamic) 
+            ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this);
         v.visitFieldOrMethod(this);
         v.visitFieldInstruction(this);
         v.visitGETSTATIC(this);

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java Tue
Dec 17 02:51:54 2013
@@ -38,7 +38,7 @@ import org.apache.bcel.util.ByteSequence
  * @version $Id: InvokeInstruction.java 1152072 2011-07-29 01:54:05Z dbrosius $
  * @author  Bill Pugh
  */
-public class INVOKEDYNAMIC extends FieldOrMethod implements ExceptionThrower,
+public class INVOKEDYNAMIC extends NameSignatureInstruction implements ExceptionThrower,
         StackConsumer, StackProducer {
 
     private static final long serialVersionUID = 1L;
@@ -71,28 +71,22 @@ public class INVOKEDYNAMIC extends Field
                 + tok.nextToken();
     }
 
-    public ConstantNameAndType getNameAndType( ConstantPoolGen cpg ) {
+    /** 
+     * Get the ConstantInvokeDynamic associated with this instruction
+     */
+    
+  	public ConstantInvokeDynamic getInvokeDynamic( ConstantPoolGen cpg ) {
+          ConstantPool cp = cpg.getConstantPool();
+          return (ConstantInvokeDynamic) cp.getConstant(index);
+       }
+      
+    @Override
+	public ConstantNameAndType getNameAndType( ConstantPoolGen cpg ) {
         ConstantPool cp = cpg.getConstantPool();
-        ConstantInvokeDynamic id = (ConstantInvokeDynamic) cp.getConstant(index);
+        ConstantInvokeDynamic id = getInvokeDynamic(cpg);
         return (ConstantNameAndType) cp.getConstant(id.getNameAndTypeIndex());
      }
     
-    /** @return signature of referenced method/field.
-     */
-    public String getSignature( ConstantPoolGen cpg ) {
-    	    ConstantPool cp = cpg.getConstantPool();
-        ConstantNameAndType cnat = getNameAndType(cpg);
-        return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes();
-    }
-
-    /** @return name of referenced method/field.
-     */
-    public String getName( ConstantPoolGen cpg ) {
-         ConstantPool cp = cpg.getConstantPool();
-         ConstantNameAndType cnat = getNameAndType(cpg);
-         return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
-    }
-
     /**
      * Also works for instructions whose stack effect depends on the
      * constant pool entry they reference.
@@ -105,7 +99,6 @@ public class INVOKEDYNAMIC extends Field
         return  Type.getArgumentTypesSize(signature);
     }
 
-
     /**
      * Also works for instructions whose stack effect depends on the
      * constant pool entry they reference.
@@ -113,8 +106,8 @@ public class INVOKEDYNAMIC extends Field
      */
     @Override
     public int produceStack( ConstantPoolGen cpg ) {
-    	String signature = getSignature(cpg);
-    	return Type.getReturnTypeSize(signature);
+        String signature = getSignature(cpg);
+        return Type.getReturnTypeSize(signature);
     }
 
 
@@ -182,10 +175,10 @@ public class INVOKEDYNAMIC extends Field
         v.visitTypedInstruction(this);
         v.visitStackConsumer(this);
         v.visitStackProducer(this);
-        v.visitLoadClass(this);
         v.visitCPInstruction(this);
-        v.visitFieldOrMethod(this);
-        if (v instanceof VisitorSupportsInvokeDynamic) 
+        if (v instanceof VisitorSupportsInvokeDynamic) {
+            ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this);
             ((VisitorSupportsInvokeDynamic)v).visitINVOKEDYNAMIC(this);
+        }
     }
 }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEINTERFACE.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEINTERFACE.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEINTERFACE.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEINTERFACE.java Tue
Dec 17 02:51:54 2013
@@ -19,6 +19,7 @@ package org.apache.bcel.generic;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+
 import org.apache.bcel.Constants;
 import org.apache.bcel.ExceptionConstants;
 import org.apache.bcel.classfile.ConstantPool;
@@ -132,6 +133,8 @@ public final class INVOKEINTERFACE exten
         v.visitStackProducer(this);
         v.visitLoadClass(this);
         v.visitCPInstruction(this);
+        if (v instanceof VisitorSupportsInvokeDynamic) 
+            ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this);
         v.visitFieldOrMethod(this);
         v.visitInvokeInstruction(this);
         v.visitINVOKEINTERFACE(this);

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKESPECIAL.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKESPECIAL.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKESPECIAL.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKESPECIAL.java Tue
Dec 17 02:51:54 2013
@@ -75,6 +75,8 @@ public class INVOKESPECIAL extends Invok
         v.visitStackProducer(this);
         v.visitLoadClass(this);
         v.visitCPInstruction(this);
+        if (v instanceof VisitorSupportsInvokeDynamic) 
+            ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this);
         v.visitFieldOrMethod(this);
         v.visitInvokeInstruction(this);
         v.visitINVOKESPECIAL(this);

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKESTATIC.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKESTATIC.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKESTATIC.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKESTATIC.java Tue
Dec 17 02:51:54 2013
@@ -72,6 +72,8 @@ public class INVOKESTATIC extends Invoke
         v.visitStackProducer(this);
         v.visitLoadClass(this);
         v.visitCPInstruction(this);
+        if (v instanceof VisitorSupportsInvokeDynamic) 
+            ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this);
         v.visitFieldOrMethod(this);
         v.visitInvokeInstruction(this);
         v.visitINVOKESTATIC(this);

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEVIRTUAL.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEVIRTUAL.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEVIRTUAL.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/INVOKEVIRTUAL.java Tue
Dec 17 02:51:54 2013
@@ -75,6 +75,8 @@ public class INVOKEVIRTUAL extends Invok
         v.visitLoadClass(this);
         v.visitCPInstruction(this);
         v.visitFieldOrMethod(this);
+        if (v instanceof VisitorSupportsInvokeDynamic) 
+            ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this);
         v.visitInvokeInstruction(this);
         v.visitINVOKEVIRTUAL(this);
     }

Added: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/NameSignatureInstruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/NameSignatureInstruction.java?rev=1551450&view=auto
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/NameSignatureInstruction.java
(added)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/NameSignatureInstruction.java
Tue Dec 17 02:51:54 2013
@@ -0,0 +1,48 @@
+package org.apache.bcel.generic;
+
+import org.apache.bcel.classfile.ConstantCP;
+import org.apache.bcel.classfile.ConstantNameAndType;
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.classfile.ConstantUtf8;
+
+/**
+ * Super class for FieldOrMethod and INVOKEDYNAMIC, since they both have
+ * names and signatures 
+ *
+ * @version $Id: FieldOrMethod.java 1481383 2013-05-11 17:34:32Z dbrosius $
+ * @author  <A HREF="mailto:bill.pugh@gmail.com">Bill Pugh</A>
+ */
+public abstract class NameSignatureInstruction extends CPInstruction {
+
+	private static final long serialVersionUID = 1L;
+
+	public NameSignatureInstruction() {
+		super();
+	}
+
+	public NameSignatureInstruction(short opcode, int index) {
+		super(opcode, index);
+	}
+
+	public ConstantNameAndType getNameAndType(ConstantPoolGen cpg) {
+	    ConstantPool cp = cpg.getConstantPool();
+	    ConstantCP cmr = (ConstantCP) cp.getConstant(index);
+	    return  (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
+	}
+	/** @return signature of referenced method/field.
+	 */
+	public String getSignature(ConstantPoolGen cpg) {
+		ConstantPool cp = cpg.getConstantPool();
+	    ConstantNameAndType cnat = getNameAndType(cpg);
+	    return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes();
+	}
+
+	/** @return name of referenced method/field.
+	 */
+	public String getName(ConstantPoolGen cpg) {
+		ConstantPool cp = cpg.getConstantPool();
+	    ConstantNameAndType cnat = getNameAndType(cpg);
+	    return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
+	}
+
+}
\ No newline at end of file

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/PUTFIELD.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/PUTFIELD.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/PUTFIELD.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/PUTFIELD.java Tue Dec
17 02:51:54 2013
@@ -79,6 +79,8 @@ public class PUTFIELD extends FieldInstr
         v.visitTypedInstruction(this);
         v.visitLoadClass(this);
         v.visitCPInstruction(this);
+        if (v instanceof VisitorSupportsInvokeDynamic) 
+            ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this);
         v.visitFieldOrMethod(this);
         v.visitFieldInstruction(this);
         v.visitPUTFIELD(this);

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/PUTSTATIC.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/PUTSTATIC.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/PUTSTATIC.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/PUTSTATIC.java Tue Dec
17 02:51:54 2013
@@ -78,6 +78,8 @@ public class PUTSTATIC extends FieldInst
         v.visitTypedInstruction(this);
         v.visitLoadClass(this);
         v.visitCPInstruction(this);
+        if (v instanceof VisitorSupportsInvokeDynamic) 
+            ((VisitorSupportsInvokeDynamic)v).visitNameSignatureInstruction(this);
         v.visitFieldOrMethod(this);
         v.visitFieldInstruction(this);
         v.visitPUTSTATIC(this);

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/VisitorSupportsInvokeDynamic.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/VisitorSupportsInvokeDynamic.java?rev=1551450&r1=1551449&r2=1551450&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/VisitorSupportsInvokeDynamic.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/generic/VisitorSupportsInvokeDynamic.java
Tue Dec 17 02:51:54 2013
@@ -2,6 +2,6 @@ package org.apache.bcel.generic;
 
 public interface VisitorSupportsInvokeDynamic extends Visitor{
 
-
+	void visitNameSignatureInstruction(NameSignatureInstruction obj);
 	void visitINVOKEDYNAMIC(INVOKEDYNAMIC obj);
 }



Mime
View raw message