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
The following commit(s) were added to refs/heads/master by this push:
new 066181c7 Sort members
066181c7 is described below
commit 066181c7beaf04d2b95f8cc8977370992c66f297
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Feb 1 15:54:22 2026 -0500
Sort members
---
src/main/java/org/apache/bcel/ExceptionConst.java | 20 +++++------
src/main/java/org/apache/bcel/util/Args.java | 26 +++++++-------
.../apache/bcel/classfile/JavaClassCyclicTest.java | 42 +++++++++++-----------
3 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/src/main/java/org/apache/bcel/ExceptionConst.java
b/src/main/java/org/apache/bcel/ExceptionConst.java
index b9b6232f..7451286c 100644
--- a/src/main/java/org/apache/bcel/ExceptionConst.java
+++ b/src/main/java/org/apache/bcel/ExceptionConst.java
@@ -49,10 +49,6 @@ public final class ExceptionConst {
EXCS_ARRAY_EXCEPTION,
}
- /** Private constructor - utility class. */
- public ExceptionConst() {
- }
-
/**
* The mother of all exceptions
*/
@@ -68,13 +64,13 @@ public final class ExceptionConst {
*/
public static final Class<LinkageError> LINKING_EXCEPTION =
LinkageError.class;
+ /** Exception class: ClassCircularityError. */
+ public static final Class<ClassCircularityError> CLASS_CIRCULARITY_ERROR =
ClassCircularityError.class;
+
/**
* Linking Exceptions.
*/
- /** Exception class: ClassCircularityError. */
- public static final Class<ClassCircularityError> CLASS_CIRCULARITY_ERROR =
ClassCircularityError.class;
-
/** Exception class: ClassFormatError. */
public static final Class<ClassFormatError> CLASS_FORMAT_ERROR =
ClassFormatError.class;
@@ -110,13 +106,13 @@ public final class ExceptionConst {
/* UnsupportedClassVersionError is new in JDK 1.2 */
// public static final Class UnsupportedClassVersionError =
UnsupportedClassVersionError.class;
+ /** Exception class: NullPointerException. */
+ public static final Class<NullPointerException> NULL_POINTER_EXCEPTION =
NullPointerException.class;
+
/**
* Run-Time Exceptions.
*/
- /** Exception class: NullPointerException. */
- public static final Class<NullPointerException> NULL_POINTER_EXCEPTION =
NullPointerException.class;
-
/** Exception class: ArrayIndexOutOfBoundsException. */
public static final Class<ArrayIndexOutOfBoundsException>
ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION = ArrayIndexOutOfBoundsException.class;
@@ -182,4 +178,8 @@ public final class ExceptionConst {
return ArrayUtils.addAll(input, extraClasses);
}
+ /** Private constructor - utility class. */
+ public ExceptionConst() {
+ }
+
}
diff --git a/src/main/java/org/apache/bcel/util/Args.java
b/src/main/java/org/apache/bcel/util/Args.java
index f0647baa..aa470244 100644
--- a/src/main/java/org/apache/bcel/util/Args.java
+++ b/src/main/java/org/apache/bcel/util/Args.java
@@ -114,19 +114,6 @@ public class Args {
return requireU2(value, 0, message);
}
- /**
- * Requires a u4 value of at least {@code min}.
- *
- * @param value The value to test.
- * @param min The minimum required value.
- * @param message The message prefix.
- * @return The value to test.
- */
- public static int requireU4(final int value, final int min, final String
message) {
- // Should really be 2^32-1, instead 2^21-1.
- return requireU4(value, min, Integer.MAX_VALUE, message);
- }
-
/**
* Requires a u4 value of at least {@code min} and not above {@code max}.
*
@@ -150,6 +137,19 @@ public class Args {
return value;
}
+ /**
+ * Requires a u4 value of at least {@code min}.
+ *
+ * @param value The value to test.
+ * @param min The minimum required value.
+ * @param message The message prefix.
+ * @return The value to test.
+ */
+ public static int requireU4(final int value, final int min, final String
message) {
+ // Should really be 2^32-1, instead 2^21-1.
+ return requireU4(value, min, Integer.MAX_VALUE, message);
+ }
+
/**
* Requires a u4 value.
*
diff --git a/src/test/java/org/apache/bcel/classfile/JavaClassCyclicTest.java
b/src/test/java/org/apache/bcel/classfile/JavaClassCyclicTest.java
index ac9e554d..93b2ac11 100644
--- a/src/test/java/org/apache/bcel/classfile/JavaClassCyclicTest.java
+++ b/src/test/java/org/apache/bcel/classfile/JavaClassCyclicTest.java
@@ -103,6 +103,27 @@ class JavaClassCyclicTest {
}
}
+ void test(final Callable<JavaClass[]> callable) throws Exception {
+ final ExecutorService executor = Executors.newSingleThreadExecutor();
+ try {
+ final Future<JavaClass[]> future = executor.submit(callable);
+ // Without fix: will timeout (infinite loop)
+ // With fix: throws ClassCircularityError immediately
+ future.get(3, TimeUnit.SECONDS);
+ fail("Should have thrown ClassCircularityError for cyclic
hierarchy");
+ } catch (final TimeoutException e) {
+ fail("Timeout: infinite loop vulnerability detected");
+ } catch (final ExecutionException e) {
+ if (e.getCause() instanceof ClassFormatException) {
+ // Expected with fix - test passes
+ return;
+ }
+ throw e;
+ } finally {
+ executor.shutdownNow();
+ }
+ }
+
/**
* Tests that getAllInterfaces() handles cyclic interface hierarchies
gracefully. BUG: Without fix, getAllInterfaces() has no visited-node check
before
* enqueueing, causing infinite queue growth and eventual heap exhaustion
(OutOfMemoryError). FIXED: With the fix, already-visited nodes are skipped,
@@ -141,25 +162,4 @@ class JavaClassCyclicTest {
void testGetSuperClassesCyclic() throws Exception {
test(cyclicClassA::getSuperClasses);
}
-
- void test(final Callable<JavaClass[]> callable) throws Exception {
- final ExecutorService executor = Executors.newSingleThreadExecutor();
- try {
- final Future<JavaClass[]> future = executor.submit(callable);
- // Without fix: will timeout (infinite loop)
- // With fix: throws ClassCircularityError immediately
- future.get(3, TimeUnit.SECONDS);
- fail("Should have thrown ClassCircularityError for cyclic
hierarchy");
- } catch (final TimeoutException e) {
- fail("Timeout: infinite loop vulnerability detected");
- } catch (final ExecutionException e) {
- if (e.getCause() instanceof ClassFormatException) {
- // Expected with fix - test passes
- return;
- }
- throw e;
- } finally {
- executor.shutdownNow();
- }
- }
}