[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-dev
Subject:    [commons-bcel] 02/02: Add and use InvalidMethodSignatureException extending ClassFormatException.
From:       ggregory () apache ! org
Date:       2023-02-25 18:33:14
Message-ID: 20230225183312.BE4F2440188 () gitbox2-he-fi ! apache ! org
[Download RAW message or body]

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit ff2e4cb477013251d43e782bf2ed3e98246864d6
Author: Gary David Gregory (Code signing key) <ggregory@apache.org>
AuthorDate: Sat Feb 25 13:33:08 2023 -0500

    Add and use InvalidMethodSignatureException extending
    ClassFormatException.
---
 pom.xml                                            | 17 ++++----
 src/changes/changes.xml                            |  3 +-
 .../classfile/InvalidMethodSignatureException.java | 49 ++++++++++++++++++++++
 .../java/org/apache/bcel/classfile/Utility.java    | 20 ++++-----
 src/main/java/org/apache/bcel/generic/Type.java    | 11 ++---
 5 files changed, 74 insertions(+), 26 deletions(-)

diff --git a/pom.xml b/pom.xml
index 26538977..3f72a932 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,7 @@
   <groupId>org.apache.bcel</groupId>
   <artifactId>bcel</artifactId>
   <packaging>jar</packaging>
-  <version>6.7.1-SNAPSHOT</version>
+  <version>6.8.0-SNAPSHOT</version>
   <name>Apache Commons BCEL</name>
   <description>Apache Commons Bytecode Engineering Library</description>
 
@@ -47,10 +47,10 @@
     <maven.compiler.target>1.8</maven.compiler.target>
     <commons.componentid>bcel</commons.componentid>
     <commons.module.name>org.apache.bcel</commons.module.name>
-    <commons.release.version>6.7.0</commons.release.version>
+    <commons.release.version>6.8.0</commons.release.version>
     <commons.release.isDistModule>true</commons.release.isDistModule>
     <commons.rc.version>RC1</commons.rc.version>
-    <commons.bc.version>6.6.1</commons.bc.version>
+    <commons.bc.version>6.7.0</commons.bc.version>
     <commons.release.desc>(Java 8)</commons.release.desc>
     <commons.scmPubUrl>https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-bcel</commons.scmPubUrl>
                
     <commons.distSvnStagingUrl>scm:svn:https://dist.apache.org/repos/dist/dev/commons/${commons.componentid}</commons.distSvnStagingUrl>
 @@ -275,13 +275,10 @@
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
-          <systemProperties>
-            <property>
-              <!-- Suppress the stats, but keep the test as it exercises the code \
                -->
-              <name>PerformanceTest.report</name>
-              <value>false</value>
-            </property>
-          </systemProperties>
+  	      <systemPropertyVariables>
+            <!-- Suppress the stats, but keep the test as it exercises the code -->
+			<PerformanceTest.report>false</PerformanceTest.report>
+		  </systemPropertyVariables>
           <includes>
             <include>**/*TestCase.java</include>
             <include>**/PerformanceTest.java</include>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b45df97e..e7ba7058 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -62,8 +62,9 @@ The <action> type attribute can be add,update,fix,remove.
    -->
 
   <body>
-    <release version="6.7.1" date="TBD" description="Maintenance and bug fix \
release."> +    <release version="6.8.0" date="TBD" description="Maintenance and bug \
fix release.">  <!-- ADD -->
+      <action                  type="add" dev="ggregory" due-to="Gary Gregory">Add \
and use InvalidMethodSignatureException extending ClassFormatException.</action>  \
<!-- FIX -->  <action                  type="fix" dev="markt" due-to="OSS-Fuzz">When \
parsing an class with an invalid constant reference, ensure ClassParser.parse() \
throws ClassFormatException, not NullPointerException.</action>  <action              \
type="fix" dev="markt" due-to="OSS-Fuzz">Ensure that references to a constant pool \
entry with index zero trigger a ClassFormatException, not a \
                NullPointerException.</action>
diff --git a/src/main/java/org/apache/bcel/classfile/InvalidMethodSignatureException.java \
b/src/main/java/org/apache/bcel/classfile/InvalidMethodSignatureException.java new \
file mode 100644 index 00000000..5e5b3823
--- /dev/null
+++ b/src/main/java/org/apache/bcel/classfile/InvalidMethodSignatureException.java
@@ -0,0 +1,49 @@
+/*
+ * 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.bcel.classfile;
+
+/**
+ * Thrown when the BCEL attempts to read a class file and determines that a class is \
malformed or otherwise cannot be interpreted as a class file. + *
+ * @since 6.8.0
+ */
+public class InvalidMethodSignatureException extends ClassFormatException {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Constructs a new instance with the specified invalid signature as the \
message. +     *
+     * @param signature The invalid signature is saved for later retrieval by the \
{@link #getMessage()} method. +     */
+    public InvalidMethodSignatureException(final String signature) {
+        super(signature);
+    }
+
+    /**
+     * Constructs a new instance with the specified invalid signature as the message \
and a cause. +     *
+     * @param signature The invalid signature is saved for later retrieval by the \
{@link #getMessage()} method. +     * @param cause     the cause (which is saved for \
later retrieval by the {@link #getCause()} method). A {@code null} value is \
permitted, and indicates that +     *                  the cause is nonexistent or \
unknown. +     */
+    public InvalidMethodSignatureException(final String signature, final Throwable \
cause) { +        super(signature, cause);
+    }
+
+}
diff --git a/src/main/java/org/apache/bcel/classfile/Utility.java \
b/src/main/java/org/apache/bcel/classfile/Utility.java index 4dcf0690..ccf348a5 \
                100644
--- a/src/main/java/org/apache/bcel/classfile/Utility.java
+++ b/src/main/java/org/apache/bcel/classfile/Utility.java
@@ -859,7 +859,7 @@ public abstract class Utility {
             // Skip any type arguments to read argument declarations between '(' and \
')'  index = signature.indexOf('(') + 1;
             if (index <= 0) {
-                throw new ClassFormatException("Invalid method signature: " + \
signature); +                throw new InvalidMethodSignatureException(signature);
             }
             while (signature.charAt(index) != ')') {
                 vec.add(typeSignatureToString(signature.substring(index), chopit));
@@ -867,7 +867,7 @@ public abstract class Utility {
                 index += unwrap(CONSUMER_CHARS); // update position
             }
         } catch (final StringIndexOutOfBoundsException e) { // Should never occur
-            throw new ClassFormatException("Invalid method signature: " + signature, \
e); +            throw new InvalidMethodSignatureException(signature, e);
         }
         return vec.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
     }
@@ -898,11 +898,11 @@ public abstract class Utility {
             // Read return type after ')'
             index = signature.lastIndexOf(')') + 1;
             if (index <= 0) {
-                throw new ClassFormatException("Invalid method signature: " + \
signature); +                throw new InvalidMethodSignatureException(signature);
             }
             type = typeSignatureToString(signature.substring(index), chopit);
         } catch (final StringIndexOutOfBoundsException e) { // Should never occur
-            throw new ClassFormatException("Invalid method signature: " + signature, \
e); +            throw new InvalidMethodSignatureException(signature, e);
         }
         return type;
     }
@@ -954,7 +954,7 @@ public abstract class Utility {
             // Skip any type arguments to read argument declarations between '(' and \
')'  index = signature.indexOf('(') + 1;
             if (index <= 0) {
-                throw new ClassFormatException("Invalid method signature: " + \
signature); +                throw new InvalidMethodSignatureException(signature);
             }
             while (signature.charAt(index) != ')') {
                 final String paramType = \
typeSignatureToString(signature.substring(index), chopit); @@ -980,7 +980,7 @@ public \
abstract class Utility {  // Read return type after ')'
             type = typeSignatureToString(signature.substring(index), chopit);
         } catch (final StringIndexOutOfBoundsException e) { // Should never occur
-            throw new ClassFormatException("Invalid method signature: " + signature, \
e); +            throw new InvalidMethodSignatureException(signature, e);
         }
         // ignore any throws information in the signature
         if (buf.length() > 1) {
@@ -1232,12 +1232,12 @@ public abstract class Utility {
         int index;
         try {
             if (signature.charAt(0) != '(') {
-                throw new ClassFormatException("Invalid method signature: " + \
signature); +                throw new InvalidMethodSignatureException(signature);
             }
             index = signature.lastIndexOf(')') + 1;
             return typeOfSignature(signature.substring(index));
         } catch (final StringIndexOutOfBoundsException e) {
-            throw new ClassFormatException("Invalid method signature: " + signature, \
e); +            throw new InvalidMethodSignatureException(signature, e);
         }
     }
 
@@ -1281,10 +1281,10 @@ public abstract class Utility {
             case '*':
                 return typeOfSignature(signature.substring(1));
             default:
-                throw new ClassFormatException("Invalid method signature: " + \
signature); +                throw new InvalidMethodSignatureException(signature);
             }
         } catch (final StringIndexOutOfBoundsException e) {
-            throw new ClassFormatException("Invalid method signature: " + signature, \
e); +            throw new InvalidMethodSignatureException(signature, e);
         }
     }
 
diff --git a/src/main/java/org/apache/bcel/generic/Type.java \
b/src/main/java/org/apache/bcel/generic/Type.java index b6ded5a9..f9158910 100644
--- a/src/main/java/org/apache/bcel/generic/Type.java
+++ b/src/main/java/org/apache/bcel/generic/Type.java
@@ -23,6 +23,7 @@ import java.util.Objects;
 
 import org.apache.bcel.Const;
 import org.apache.bcel.classfile.ClassFormatException;
+import org.apache.bcel.classfile.InvalidMethodSignatureException;
 import org.apache.bcel.classfile.Utility;
 
 /**
@@ -84,7 +85,7 @@ public abstract class Type {
             // Skip any type arguments to read argument declarations between '(' and \
')'  index = signature.indexOf('(') + 1;
             if (index <= 0) {
-                throw new ClassFormatException("Invalid method signature: " + \
signature); +                throw new InvalidMethodSignatureException(signature);
             }
             while (signature.charAt(index) != ')') {
                 vec.add(getType(signature.substring(index)));
@@ -92,7 +93,7 @@ public abstract class Type {
                 index += unwrap(CONSUMED_CHARS); // update position
             }
         } catch (final StringIndexOutOfBoundsException e) { // Should never occur
-            throw new ClassFormatException("Invalid method signature: " + signature, \
e); +            throw new InvalidMethodSignatureException(signature, e);
         }
         final Type[] types = new Type[vec.size()];
         vec.toArray(types);
@@ -106,7 +107,7 @@ public abstract class Type {
             // Skip any type arguments to read argument declarations between '(' and \
')'  index = signature.indexOf('(') + 1;
             if (index <= 0) {
-                throw new ClassFormatException("Invalid method signature: " + \
signature); +                throw new InvalidMethodSignatureException(signature);
             }
             while (signature.charAt(index) != ')') {
                 final int coded = getTypeSize(signature.substring(index));
@@ -114,7 +115,7 @@ public abstract class Type {
                 index += consumed(coded);
             }
         } catch (final StringIndexOutOfBoundsException e) { // Should never occur
-            throw new ClassFormatException("Invalid method signature: " + signature, \
e); +            throw new InvalidMethodSignatureException(signature, e);
         }
         return res;
     }
@@ -150,7 +151,7 @@ public abstract class Type {
             final int index = signature.lastIndexOf(')') + 1;
             return getType(signature.substring(index));
         } catch (final StringIndexOutOfBoundsException e) { // Should never occur
-            throw new ClassFormatException("Invalid method signature: " + signature, \
e); +            throw new InvalidMethodSignatureException(signature, e);
         }
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic