Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

new files for fix to BYTEMAN-219

  • Loading branch information...
commit 29c98709ce25a51be632da23bc84ef2397424df9 1 parent 19c2683
@adinn authored
View
30 agent/pom.xml
@@ -779,6 +779,21 @@
<argLine>-javaagent:${project.build.directory}/byteman-${project.version}.jar=script:${project.build.testOutputDirectory}/scripts/bugfixes/TestAfterCallAssign.btm</argLine>
</configuration>
</execution>
+ <execution>
+ <id>bugfixes.TestAbstractInterfaceCall</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <forkMode>once</forkMode>
+ <includes>
+ <include>org/jboss/byteman/tests/bugfixes/TestAbstractInterfaceCall.class</include>
+ </includes>
+ <argLine>-javaagent:${project.build.directory}/byteman-${project.version}.jar=script:${project.build.testOutputDirectory}/scripts/bugfixes/TestAbstractInterfaceCall.btm</argLine>
+ </configuration>
+ </execution>
<!-- dynamic rule submission
n.b. submit test does not use a script on the command line
instead it sets listener true and uplaods the rules from the test program
@@ -1464,6 +1479,21 @@
<argLine>-Dorg.jboss.byteman.compile.to.bytecode -javaagent:${project.build.directory}/byteman-${project.version}.jar=script:${project.build.testOutputDirectory}/scripts/bugfixes/TestAfterCallAssign.btm</argLine>
</configuration>
</execution>
+ <execution>
+ <id>bugfixes.TestAbstractInterfaceCall.compiled</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <forkMode>once</forkMode>
+ <includes>
+ <include>org/jboss/byteman/tests/bugfixes/TestAbstractInterfaceCall.class</include>
+ </includes>
+ <argLine>-Dorg.jboss.byteman.compile.to.bytecode -javaagent:${project.build.directory}/byteman-${project.version}.jar=script:${project.build.testOutputDirectory}/scripts/bugfixes/TestAbstractInterfaceCall.btm</argLine>
+ </configuration>
+ </execution>
<!-- dynamic rule submission compiled
submit test does not use a script on the command line
instead it sets listener true and uplaods the rules from the test program
View
2  agent/src/main/java/org/jboss/byteman/rule/expression/MethodExpression.java
@@ -413,7 +413,7 @@ public void compile(MethodVisitor mv, CompileContext compileContext) throws Comp
if (recipient == null) {
mv.visitMethodInsn(Opcodes.INVOKESTATIC, ownerName, method.getName(), getDescriptor());
- } else if (recipient.getClass().isInterface()) {
+ } else if (method.getDeclaringClass().isInterface()) {
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, ownerName, method.getName(), getDescriptor());
} else {
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, ownerName, method.getName(), getDescriptor());
View
41 agent/src/test/java/org/jboss/byteman/tests/auxiliary/C3.java
@@ -1,11 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @authors Andrew Dinn
+ */
+
package org.jboss.byteman.tests.auxiliary;
+import org.jboss.byteman.tests.Test;
+
/**
- * Created by IntelliJ IDEA.
- * User: adinn
- * Date: 26/11/12
- * Time: 12:31
- * To change this template use File | Settings | File Templates.
+ * test class for fix to BYTEMAN-219
*/
-public class C3 {
+public abstract class C3 implements I5
+{
+ // n.b. this class does not implement interfaceMethod() inherited from I5
+ // but it's instantiable subclasses always will!
+ public void testMethod(Test test)
+ {
+ test.log("inside C3.testMethod");
+ }
}
View
40 agent/src/test/java/org/jboss/byteman/tests/auxiliary/C4.java
@@ -1,11 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @authors Andrew Dinn
+ */
+
package org.jboss.byteman.tests.auxiliary;
+import org.jboss.byteman.tests.Test;
+
/**
- * Created by IntelliJ IDEA.
- * User: adinn
- * Date: 26/11/12
- * Time: 12:33
- * To change this template use File | Settings | File Templates.
+ * test class for fix to BYTEMAN-219
*/
-public class C4 {
+public class C4 extends C3
+{
+ // this non-abstract class has to implement interfaceMethod() inherited from I5 via C3
+ public void interfaceMethod(Test test)
+ {
+ test.log("inside C4.interfaceMethod");
+ }
}
View
36 agent/src/test/java/org/jboss/byteman/tests/auxiliary/I5.java
@@ -1,11 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @authors Andrew Dinn
+ */
+
package org.jboss.byteman.tests.auxiliary;
+import org.jboss.byteman.tests.Test;
+
/**
- * Created by IntelliJ IDEA.
- * User: adinn
- * Date: 26/11/12
- * Time: 12:30
- * To change this template use File | Settings | File Templates.
+ * test class for fix to BYTEMAN-219
*/
-public class I5 {
+public interface I5
+{
+ public void interfaceMethod(Test test);
}
View
70 agent/src/test/java/org/jboss/byteman/tests/bugfixes/TestAbstractInterfaceCall.java
@@ -1,11 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2012, Red Hat and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*
+* @authors Andrew Dinn
+*/
package org.jboss.byteman.tests.bugfixes;
+import org.jboss.byteman.tests.Test;
+import org.jboss.byteman.tests.auxiliary.C3;
+import org.jboss.byteman.tests.auxiliary.C4;
+import org.jboss.byteman.tests.auxiliary.I5;
+
+
/**
- * Created by IntelliJ IDEA.
- * User: adinn
- * Date: 26/11/12
- * Time: 12:26
- * To change this template use File | Settings | File Templates.
+ * Test for BYTEMAN-219 where a call to an interface method of an abstract class failed to typecheck
+ * because there was no implementation on the abstract class.
*/
-public class TestAbstractInterfaceCall {
-}
+public class TestAbstractInterfaceCall extends Test
+{
+ private int run;
+
+ public TestAbstractInterfaceCall()
+ {
+ super(TestAbstractInterfaceCall.class.getCanonicalName());
+ }
+
+ public void test()
+ {
+ C4 c4 = new C4();
+ try {
+ log("calling C4.testMethod");
+ c4.testMethod(this);
+ log("called C4.testMethod");
+ } catch (Exception e) {
+ log(e);
+ }
+
+ checkOutput(true);
+ }
+
+ @Override
+ public String getExpected() {
+ logExpected("calling C4.testMethod");
+ logExpected("inside C4.interfaceMethod");
+ logExpected("inside C3.testMethod");
+ logExpected("called C4.testMethod");
+ return super.getExpected();
+ }
+}
View
29 agent/src/test/resources/scripts/bugfixes/TestAbstractInterfaceCall.btm
@@ -21,23 +21,22 @@
#
# @authors Andrew Dinn
#
-# Test for bug reported by Flavia Rainone JIRA BYTEMAN-140 where the Transformer
-# injection through interfaces was failing to traverse the interface extends hierarchy.
-
-RULE test interface injection without overriding
-INTERFACE I3
-METHOD testMethod(Test)
-HELPER org.jboss.byteman.tests.helpers.Default
-BIND test : TestInterfaceHierarchy = $1
-IF TRUE
-DO test.log("I3.testMethod() AT ENTRY");
-ENDRULE
+# Test for BYTEMAN-219 to ensure that it is possible to call an interface method
+# inherited by an abstract class even if the abstract class does not iself
+# implement the method. the interface method will always be defined by any
+# instantiable subclass so a call to the method should typecheck ands execute
+# correctly.
+#
+# in this example C3 is an abstract class which implements interface I4
+# but leaves it to its subclass C4 to provide the actual implementation of
+# method interfaceMethod. The type checker should still detect that this
+# method can safely be called on any instance of C3.
-RULE test interface injection with overriding
-INTERFACE ^I3
+RULE test abstract interface method call
+CLASS C3
METHOD testMethod(Test)
HELPER org.jboss.byteman.tests.helpers.Default
-BIND test : TestInterfaceHierarchy = $1
+BIND test : TestAbstractInterfaceCall = $1
IF TRUE
-DO test.log("^I3.testMethod() AT ENTRY");
+DO $0.interfaceMethod(test)
ENDRULE
Please sign in to comment.
Something went wrong with that request. Please try again.