[Git][java-team/byteman][upstream] New upstream version 4.0.20

Andrius Merkys (@merkys) gitlab at salsa.debian.org
Mon Oct 24 12:53:19 BST 2022



Andrius Merkys pushed to branch upstream at Debian Java Maintainers / byteman


Commits:
7d05a279 by Andrius Merkys at 2022-10-24T07:05:19-04:00
New upstream version 4.0.20
- - - - -


21 changed files:

- agent/pom.xml
- agent/src/main/java/org/jboss/byteman/agent/RuleScript.java
- agent/src/main/java/org/jboss/byteman/rule/expression/MethodExpression.java
- + agent/src/test/java/org/jboss/byteman/tests/bugfixes/TestNonPublicArgAccess.java
- + agent/src/test/resources/scripts/bugfixes/TestNonPublicArgAccess.btm
- byteman/pom.xml
- contrib/bmunit/pom.xml
- contrib/bmunit5/pom.xml
- contrib/dtest/pom.xml
- contrib/rulecheck-maven-plugin/example/pom.xml
- contrib/rulecheck-maven-plugin/pom.xml
- docs/asciidoc/pom.xml
- docs/pom.xml
- download/pom.xml
- install/pom.xml
- jigsaw/pom.xml
- layer/pom.xml
- pom.xml
- sample/pom.xml
- submit/pom.xml
- tests/pom.xml


Changes:

=====================================
agent/pom.xml
=====================================
@@ -34,7 +34,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
     </parent>
 
     <properties>
@@ -1229,7 +1229,7 @@
                       </configuration>
                     </execution>
                     <execution>
-                      <id>javaops.TestInnerClasses</id>
+                      <id>bugfixes.TestInnerClasses</id>
                       <phase>integration-test</phase>
                       <goals>
                         <goal>integration-test</goal>
@@ -1260,6 +1260,25 @@
                          <argLine>-javaagent:${project.build.directory}/byteman-agent-${project.version}.jar=script:${project.build.testOutputDirectory}/scripts/bugfixes/TestAsTarget.btm</argLine>
                       </configuration>
                     </execution>
+                    <execution>
+                        <!-- n.b. this test only applies for compiled usage
+                        the test specifies COMPILED in the rule so there
+                        is no equivalent compield variant of this test. -->
+                        <id>bugfixes.TestNonPublicArgAccess</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                        <configuration>
+                            <forkCount>1</forkCount>
+                            <reuseForks>true</reuseForks>
+                            <includes>
+                                <include>org/jboss/byteman/tests/bugfixes/TestNonPublicArgAccess.class</include>
+                            </includes>
+                            <argLine>-javaagent:${project.build.directory}/byteman-agent-${project.version}.jar=script:${project.build.testOutputDirectory}/scripts/bugfixes/TestNonPublicArgAccess.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


=====================================
agent/src/main/java/org/jboss/byteman/agent/RuleScript.java
=====================================
@@ -390,7 +390,8 @@ public class RuleScript
         for (Transform transform : transformSet.getTransforms()) {
             // transform may not employ the same rule
             // but it may have the same key.
-            if(transform.getRule().getKey() == rule.getKey()) {
+            Rule transformRule = transform.getRule();
+            if (transformRule != null && transformRule.getKey() == rule.getKey()) {
                 transform.setCompiled(successful, detail);
                 boolean isInstalled = transformSet.isInstalled();
                 // record this as the latest rule to be installed


=====================================
agent/src/main/java/org/jboss/byteman/rule/expression/MethodExpression.java
=====================================
@@ -308,8 +308,8 @@ public class MethodExpression extends Expression
 
                 if (method != null) {
                     Type declaringType = getTypeGroup().ensureType(method.getDeclaringClass());
-                    if (rule.requiresAccess(declaringType) || rule.requiresAccess(method)) {
-                        isPublicMethod  = false;
+                    if (requiresAccess(declaringType, method, argumentTypes)) {
+                        isPublicMethod = false;
                         // save the method so we can use it from the compiled code
                         methodIndex = rule.addAccessibleMethodInvoker(method);
                     } else {
@@ -330,6 +330,19 @@ public class MethodExpression extends Expression
         // no more possible candidates so throw up here
         throw new TypeException("MethodExpression.typeCheck : invalid method " + name + " for target class " + rootType.getName() + getPos());
     }
+    private boolean requiresAccess(Type declaringType, Method method, List<Type> argumentTypes) {
+        // 1. check if declaring type or method have restricted access
+        if (rule.requiresAccess(declaringType) || rule.requiresAccess(method)) {
+            return true;
+        }
+        // 2. check if passed arguments have restricted access
+        for (Type argumentType : argumentTypes) {
+            if (rule.requiresAccess(argumentType)) {
+                return true;
+            }
+        }
+        return false;
+    }
 
     public Object interpret(HelperAdapter helper) throws ExecuteException {
         Object recipientValue = null;


=====================================
agent/src/test/java/org/jboss/byteman/tests/bugfixes/TestNonPublicArgAccess.java
=====================================
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2022, 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;
+
+/*
+ * Test case for BYTEMAN-425
+ *
+ * Check that rules which receive a value with a non-public type can
+ * invoke a method which expects an argument belonging to the non-public
+ * type, its super or one of its interfaces. This is never a problem for
+ * non-compiled rules because all operations are performed either
+ * reflectively or using method handles where arguments are stored and
+ * passed as generic objects. However, with rules that are compiled to
+ * bytecode the non-public type cannot be referenced from the generated
+ * bytecode. The compiler needs to recognize such cases and execute the
+ * method by passing the value as a generic object to a reflective method
+ * or method handle rather than using a direct or virtual call.
+ *
+ */
+
+public class TestNonPublicArgAccess extends Test {
+    public TestNonPublicArgAccess() {
+        super("org.jboss.byteman.tests.access.TestNonPublicArgAccess");
+    }
+
+    public void test()
+    {
+        try {
+            TestArg arg = new TestArg("Byteman!");
+            log("calling TestAccess.triggerMethod()");
+            triggerMethod(arg);
+            log("called TestAccess.triggerMethod()");
+        } catch (Exception e) {
+            log(e);
+        }
+
+        checkOutput(true);
+    }
+
+    // Method into which rule will be injected
+    private void triggerMethod(TestArg arg)
+    {
+        log("inside TestAccess.triggerMethod()");
+    }
+
+    // Method rule will call to test private argtype detection
+    public void logArgValue(TestArgAbstract arg)
+    {
+        log("Argument is " + arg.value());
+    }
+
+    @Override
+    public String getExpected() {
+        logExpected("calling TestAccess.triggerMethod()");
+        logExpected("triggerMethod arg = Byteman!");
+        logExpected("Argument is Byteman!");
+        logExpected("inside TestAccess.triggerMethod()");
+        logExpected("called TestAccess.triggerMethod()");
+
+        return super.getExpected();
+    }
+
+    public abstract static class TestArgAbstract {
+        public abstract String value();
+    }
+
+    static class TestArg extends TestArgAbstract {
+        private final String value;
+        public TestArg(String value) {
+            this.value = value;
+        }
+        @Override
+        // Method rule will call to test private owner type detection
+        public String value() {
+            return value;
+        }
+    }
+}


=====================================
agent/src/test/resources/scripts/bugfixes/TestNonPublicArgAccess.btm
=====================================
@@ -0,0 +1,36 @@
+##############################################################################
+# JBoss, Home of Professional Open Source
+# Copyright 2022, 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
+#
+# Test case for BYTEMAN-425 to ensure that we can call a method
+# with a value whose type is non-public
+
+RULE test non public argument access
+CLASS TestNonPublicArgAccess
+METHOD triggerMethod
+AT ENTRY
+COMPILE
+HELPER org.jboss.byteman.tests.helpers.Default
+IF TRUE
+DO $0.log("triggerMethod arg = " + $1.value());
+   $0.logArgValue($1);
+ENDRULE


=====================================
byteman/pom.xml
=====================================
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
     </parent>
 
     <description>


=====================================
contrib/bmunit/pom.xml
=====================================
@@ -32,7 +32,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
         <relativePath>../../pom.xml</relativePath>
     </parent>
     <build>


=====================================
contrib/bmunit5/pom.xml
=====================================
@@ -32,7 +32,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
         <relativePath>../../pom.xml</relativePath>
     </parent>
     <build>


=====================================
contrib/dtest/pom.xml
=====================================
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
         <relativePath>../../pom.xml</relativePath>
     </parent>
     <dependencies>


=====================================
contrib/rulecheck-maven-plugin/example/pom.xml
=====================================
@@ -18,7 +18,7 @@
       <plugin>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-rulecheck-maven-plugin</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
         <executions>
           <execution>
             <id>rulecheck-test</id>


=====================================
contrib/rulecheck-maven-plugin/pom.xml
=====================================
@@ -32,7 +32,7 @@
 	<parent>
 		<groupId>org.jboss.byteman</groupId>
 		<artifactId>byteman-root</artifactId>
-		<version>4.0.19</version>
+		<version>4.0.20</version>
 		<relativePath>../../pom.xml</relativePath>
 	</parent>
 


=====================================
docs/asciidoc/pom.xml
=====================================
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.jboss.byteman</groupId>
     <artifactId>byteman-docs</artifactId>
-    <version>4.0.19</version>
+    <version>4.0.20</version>
   </parent>
     
   <artifactId>byteman-asciidoc</artifactId>


=====================================
docs/pom.xml
=====================================
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.jboss.byteman</groupId>
     <artifactId>byteman-root</artifactId>
-    <version>4.0.19</version>
+    <version>4.0.20</version>
   </parent>
     
   <artifactId>byteman-docs</artifactId>


=====================================
download/pom.xml
=====================================
@@ -28,7 +28,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
     </parent>
     <description>
         The Byteman download includes the byteman agent, submit and install jars. the contributed


=====================================
install/pom.xml
=====================================
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
     </parent>
 
     <profiles>


=====================================
jigsaw/pom.xml
=====================================
@@ -41,7 +41,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
     </parent>
     <properties>
         <!-- don't install or deploy this jar, instead use it to


=====================================
layer/pom.xml
=====================================
@@ -36,7 +36,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
     </parent>
     <build>
         <plugins>


=====================================
pom.xml
=====================================
@@ -33,7 +33,7 @@
         into Java application and JVM runtime methods. Its primary purpose is to support execution tracing and fault
         injection testing.
     </description>
-    <version>4.0.19</version>
+    <version>4.0.20</version>
     <name>byteman-root</name>
     <url>http://www.jboss.org/byteman</url>
 
@@ -106,7 +106,7 @@
         <!-- for testing: command line args to enable debugger and verbose trace -->
         <debug.args>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Dorg.jboss.byteman.verbose</debug.args>
         <!-- asm release version to use -->
-        <asm.version>9.3</asm.version>
+        <asm.version>9.4</asm.version>
         <!-- maven-verification-plugin -->
         <tests.verification.file>access-verification.xml</tests.verification.file>
         <agent.verification.file>verification.xml</agent.verification.file>


=====================================
sample/pom.xml
=====================================
@@ -28,7 +28,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
     </parent>
     <description>
         The Byteman sample jar contains some example helper classes and auxiliary classes used by the]


=====================================
submit/pom.xml
=====================================
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
     </parent>
     <build>
       <plugins>


=====================================
tests/pom.xml
=====================================
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.jboss.byteman</groupId>
         <artifactId>byteman-root</artifactId>
-        <version>4.0.19</version>
+        <version>4.0.20</version>
     </parent>
 
     <description>
@@ -1240,6 +1240,25 @@
                          <argLine>-javaagent:${project.build.directory}/../../byteman/target/byteman-${project.version}.jar=listener:true</argLine>
                       </configuration>
                     </execution>
+                    <execution>
+                        <!-- n.b. this test only applies for compiled usage
+                        the test specifies COMPILED in the rule so there
+                        is no equivalent compield variant of this test. -->
+                        <id>bugfixes.TestNonPublicArgAccess</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                        <configuration>
+                            <forkCount>1</forkCount>
+                            <reuseForks>true</reuseForks>
+                            <includes>
+                                <include>org/jboss/byteman/tests/bugfixes/TestNonPublicArgAccess.class</include>
+                            </includes>
+                            <argLine>-javaagent:${project.build.directory}../../byteman/target/byteman-agent-${project.version}.jar=script:${project.build.directory}/../../agent/src/test/resources/cripts/bugfixes/TestNonPublicArgAccess.btm</argLine>
+                        </configuration>
+                    </execution>
                     <!-- now the executions for the compiled rules -->
                     <!-- java language operations compiled -->
                     <execution>



View it on GitLab: https://salsa.debian.org/java-team/byteman/-/commit/7d05a27964a7d1f63e7f84f85546f74d04d0f857

-- 
View it on GitLab: https://salsa.debian.org/java-team/byteman/-/commit/7d05a27964a7d1f63e7f84f85546f74d04d0f857
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20221024/c3f1611b/attachment.htm>


More information about the pkg-java-commits mailing list