You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2015/09/11 14:37:22 UTC

svn commit: r1702447 - in /commons/proper/bcel/trunk/src: changes/changes.xml main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java test/java/org/apache/commons/bcel6/util/BCELifierTestCase.java

Author: sebb
Date: Fri Sep 11 12:37:21 2015
New Revision: 1702447

URL: http://svn.apache.org/r1702447
Log:
BCEL-221 BCELifier is not working for Java8Example
Workround for crash; may need further work

Modified:
    commons/proper/bcel/trunk/src/changes/changes.xml
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java
    commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/util/BCELifierTestCase.java

Modified: commons/proper/bcel/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/changes/changes.xml?rev=1702447&r1=1702446&r2=1702447&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/changes/changes.xml (original)
+++ commons/proper/bcel/trunk/src/changes/changes.xml Fri Sep 11 12:37:21 2015
@@ -63,6 +63,7 @@ The <action> type attribute can be add,u
 
   <body>
     <release version="6.0" date="TBA" description="Major release with Java 7 and 8 support">
+      <action issue="BCEL-221" type="fix">BCELifier is not working for Java8Example</action>
       <action issue="BCEL-195" type="fix">addition of hashCode() to generic/Instruction.java breaks Targeters. Never make distinct BranchInstructions compare equal</action>
       <action issue="BCEL-261" type="fix">Select constructor allows partially constructed instance to escape. Re-ordered code to delay the escape.</action>
       <action issue="BCEL-259" type="fix">Minor doc error in BranchInstruction.java</action>

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java?rev=1702447&r1=1702446&r2=1702447&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java Fri Sep 11 12:37:21 2015
@@ -22,6 +22,8 @@ import java.io.IOException;
 
 import org.apache.commons.bcel6.Const;
 import org.apache.commons.bcel6.ExceptionConst;
+import org.apache.commons.bcel6.classfile.ConstantInvokeDynamic;
+import org.apache.commons.bcel6.classfile.ConstantNameAndType;
 import org.apache.commons.bcel6.classfile.ConstantPool;
 import org.apache.commons.bcel6.util.ByteSequence;
 
@@ -115,4 +117,13 @@ public class INVOKEDYNAMIC extends Invok
         v.visitInvokeInstruction(this);
         v.visitINVOKEDYNAMIC(this);
     }
+
+    /**
+     * Override the parent method because our classname is held elsewhere.
+     */
+    public String getClassName( ConstantPoolGen cpg ) {
+        ConstantPool cp = cpg.getConstantPool();
+        ConstantInvokeDynamic cid = (ConstantInvokeDynamic) cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic);
+        return ((ConstantNameAndType) cp.getConstant(cid.getNameAndTypeIndex())).getName(cp);
+    }
 }

Modified: commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/util/BCELifierTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/util/BCELifierTestCase.java?rev=1702447&r1=1702446&r2=1702447&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/util/BCELifierTestCase.java (original)
+++ commons/proper/bcel/trunk/src/test/java/org/apache/commons/bcel6/util/BCELifierTestCase.java Fri Sep 11 12:37:21 2015
@@ -2,21 +2,20 @@ package org.apache.commons.bcel6.util;
 
 import static org.junit.Assert.*;
 
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+
 import org.apache.commons.bcel6.classfile.JavaClass;
 import org.junit.Test;
-import static org.junit.Assume.assumeTrue;
 
 public class BCELifierTestCase {
 
-    // A bit of a hack - we use the same property as for the perf test for now
-    private static final boolean REPORT = Boolean.parseBoolean(System.getProperty("PerformanceTest.report", "true"));;
-
     @Test
     public void test() throws Exception {
-        assumeTrue(REPORT); // set to false by pom so this will only run on demand
+        OutputStream os = new ByteArrayOutputStream();
         JavaClass java_class = BCELifier.getJavaClass("Java8Example");
         assertNotNull(java_class);
-        BCELifier bcelifier = new BCELifier(java_class, System.out);
+        BCELifier bcelifier = new BCELifier(java_class, os);
         bcelifier.start();
     }