You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/06/22 18:57:28 UTC
(commons-bcel) 01/02: Sort members
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 4e10d23275f7dff337433de5d4d7910c0337a606
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Sat Jun 22 14:57:07 2024 -0400
Sort members
---
src/examples/Mini/Environment.java | 8 +-
.../org/apache/bcel/classfile/FieldOrMethod.java | 14 +--
.../java/org/apache/bcel/classfile/JavaClass.java | 14 +--
.../java/org/apache/bcel/classfile/Module.java | 106 ++++++++++-----------
.../org/apache/bcel/classfile/ModuleExports.java | 74 +++++++-------
.../org/apache/bcel/classfile/ModuleOpens.java | 74 +++++++-------
.../org/apache/bcel/classfile/ModuleProvides.java | 66 ++++++-------
.../org/apache/bcel/classfile/ModuleRequires.java | 58 +++++------
.../org/apache/bcel/AnonymousClassTestCase.java | 14 +--
.../bcel/LocalVariableTypeTableTestCase.java | 32 +++----
10 files changed, 230 insertions(+), 230 deletions(-)
diff --git a/src/examples/Mini/Environment.java b/src/examples/Mini/Environment.java
index 49c36833..ead95614 100644
--- a/src/examples/Mini/Environment.java
+++ b/src/examples/Mini/Environment.java
@@ -35,14 +35,14 @@ public class Environment implements Cloneable {
this(SIZE);
}
- public Environment(final int size) {
- table = new ConcurrentHashMap<>(size);
- }
-
private Environment(final ConcurrentHashMap<String, EnvEntry> table) {
this.table = table;
}
+ public Environment(final int size) {
+ table = new ConcurrentHashMap<>(size);
+ }
+
@Override
public Object clone() {
return new Environment(new ConcurrentHashMap<>(table));
diff --git a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java
index f67c1be7..bc13135a 100644
--- a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java
+++ b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java
@@ -164,13 +164,6 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
return annotationEntries;
}
- /**
- * @return Collection of object attributes.
- */
- public final Attribute[] getAttributes() {
- return attributes;
- }
-
/**
* Gets attribute for given tag.
* @return Attribute for given tag, null if not found.
@@ -187,6 +180,13 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
return null;
}
+ /**
+ * @return Collection of object attributes.
+ */
+ public final Attribute[] getAttributes() {
+ return attributes;
+ }
+
/**
* @return Constant pool used by this object.
*/
diff --git a/src/main/java/org/apache/bcel/classfile/JavaClass.java b/src/main/java/org/apache/bcel/classfile/JavaClass.java
index fa49fbc3..93bfbe11 100644
--- a/src/main/java/org/apache/bcel/classfile/JavaClass.java
+++ b/src/main/java/org/apache/bcel/classfile/JavaClass.java
@@ -482,13 +482,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
return annotations;
}
- /**
- * @return Attributes of the class.
- */
- public Attribute[] getAttributes() {
- return attributes;
- }
-
/**
* Gets attribute for given tag.
* @return Attribute for given tag, null if not found.
@@ -505,6 +498,13 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
return null;
}
+ /**
+ * @return Attributes of the class.
+ */
+ public Attribute[] getAttributes() {
+ return attributes;
+ }
+
/**
* @return class in binary format
*/
diff --git a/src/main/java/org/apache/bcel/classfile/Module.java b/src/main/java/org/apache/bcel/classfile/Module.java
index 5915522c..3e8c9fb9 100644
--- a/src/main/java/org/apache/bcel/classfile/Module.java
+++ b/src/main/java/org/apache/bcel/classfile/Module.java
@@ -40,15 +40,23 @@ public final class Module extends Attribute {
*/
public static final String EXTENSION = ".jmod";
+ private static String getClassNameAtIndex(final ConstantPool cp, final int index, final boolean compactClassName) {
+ final String className = cp.getConstantString(index, Const.CONSTANT_Class);
+ if (compactClassName) {
+ return Utility.compactClassName(className, false);
+ }
+ return className;
+ }
private final int moduleNameIndex;
private final int moduleFlags;
- private final int moduleVersionIndex;
+ private final int moduleVersionIndex;
private ModuleRequires[] requiresTable;
private ModuleExports[] exportsTable;
private ModuleOpens[] opensTable;
private final int usesCount;
private final int[] usesIndex;
+
private ModuleProvides[] providesTable;
/**
@@ -109,58 +117,6 @@ public final class Module extends Attribute {
v.visitModule(this);
}
- /**
- * Gets version for this module.
- * @param cp Array of constants
- * @return version from constant pool, "0" if version index is 0
- * @since 6.10.0
- */
- public String getVersion(final ConstantPool cp) {
- return moduleVersionIndex == 0 ? "0" : cp.getConstantString(moduleVersionIndex, Const.CONSTANT_Utf8);
- }
-
- /**
- * Gets flags for this module.
- * @return module flags
- * @since 6.10.0
- */
- public int getModuleFlags() {
- return moduleFlags;
- }
-
- /**
- * Gets module name.
- * @param cp Array of constants
- * @return module name
- * @since 6.10.0
- */
- public String getModuleName(final ConstantPool cp) {
- return cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module);
- }
-
- /**
- * Gets the array of class names for this module's uses.
- * @param constantPool Array of constants usually obtained from the ClassFile object
- * @param compactClassName false for original constant pool value, true to replace '/' with '.'
- * @return array of used class names
- * @since 6.10.0
- */
- public String[] getUsedClassNames(final ConstantPool constantPool, final boolean compactClassName) {
- final String[] usedClassNames = new String[usesCount];
- for (int i = 0; i < usesCount; i++) {
- usedClassNames[i] = getClassNameAtIndex(constantPool, usesIndex[i], compactClassName);
- }
- return usedClassNames;
- }
-
- private static String getClassNameAtIndex(final ConstantPool cp, final int index, final boolean compactClassName) {
- final String className = cp.getConstantString(index, Const.CONSTANT_Class);
- if (compactClassName) {
- return Utility.compactClassName(className, false);
- }
- return className;
- }
-
/**
* @return deep copy of this attribute
*/
@@ -232,6 +188,25 @@ public final class Module extends Attribute {
return exportsTable;
}
+ /**
+ * Gets flags for this module.
+ * @return module flags
+ * @since 6.10.0
+ */
+ public int getModuleFlags() {
+ return moduleFlags;
+ }
+
+ /**
+ * Gets module name.
+ * @param cp Array of constants
+ * @return module name
+ * @since 6.10.0
+ */
+ public String getModuleName(final ConstantPool cp) {
+ return cp.getConstantString(moduleNameIndex, Const.CONSTANT_Module);
+ }
+
/**
* @return table of provided interfaces
* @see ModuleOpens
@@ -256,6 +231,31 @@ public final class Module extends Attribute {
return requiresTable;
}
+ /**
+ * Gets the array of class names for this module's uses.
+ * @param constantPool Array of constants usually obtained from the ClassFile object
+ * @param compactClassName false for original constant pool value, true to replace '/' with '.'
+ * @return array of used class names
+ * @since 6.10.0
+ */
+ public String[] getUsedClassNames(final ConstantPool constantPool, final boolean compactClassName) {
+ final String[] usedClassNames = new String[usesCount];
+ for (int i = 0; i < usesCount; i++) {
+ usedClassNames[i] = getClassNameAtIndex(constantPool, usesIndex[i], compactClassName);
+ }
+ return usedClassNames;
+ }
+
+ /**
+ * Gets version for this module.
+ * @param cp Array of constants
+ * @return version from constant pool, "0" if version index is 0
+ * @since 6.10.0
+ */
+ public String getVersion(final ConstantPool cp) {
+ return moduleVersionIndex == 0 ? "0" : cp.getConstantString(moduleVersionIndex, Const.CONSTANT_Utf8);
+ }
+
/**
* @return String representation, i.e., a list of packages.
*/
diff --git a/src/main/java/org/apache/bcel/classfile/ModuleExports.java b/src/main/java/org/apache/bcel/classfile/ModuleExports.java
index 5653e82d..34460c42 100644
--- a/src/main/java/org/apache/bcel/classfile/ModuleExports.java
+++ b/src/main/java/org/apache/bcel/classfile/ModuleExports.java
@@ -32,9 +32,13 @@ import org.apache.bcel.Const;
*/
public final class ModuleExports implements Cloneable, Node {
+ private static String getToModuleNameAtIndex(final ConstantPool constantPool, final int index) {
+ return constantPool.getConstantString(index, Const.CONSTANT_Module);
+ }
private final int exportsIndex; // points to CONSTANT_Package_info
private final int exportsFlags;
private final int exportsToCount;
+
private final int[] exportsToIndex; // points to CONSTANT_Module_info
/**
@@ -53,43 +57,6 @@ public final class ModuleExports implements Cloneable, Node {
}
}
- /**
- * Gets the flags for this ModuleExports.
- * @return the exportsFlags
- * @since 6.10.0
- */
- public int getExportsFlags() {
- return exportsFlags;
- }
-
- /**
- * Gets an array of module names for this ModuleExports.
- * @param constantPool Array of constants usually obtained from the ClassFile object
- * @return array of module names following 'exports to'
- * @since 6.10.0
- */
- public String[] getToModuleNames(final ConstantPool constantPool) {
- final String[] toModuleNames = new String[exportsToCount];
- for (int i = 0; i < exportsToCount; i++) {
- toModuleNames[i] = getToModuleNameAtIndex(constantPool, exportsToIndex[i]);
- }
- return toModuleNames;
- }
-
- private static String getToModuleNameAtIndex(final ConstantPool constantPool, final int index) {
- return constantPool.getConstantString(index, Const.CONSTANT_Module);
- }
-
- /**
- * Gets the exported package name.
- * @param constantPool the constant pool from the ClassFile
- * @return the exported package name
- * @since 6.10.0
- */
- public String getPackageName(final ConstantPool constantPool) {
- return constantPool.constantToString(exportsIndex, Const.CONSTANT_Package);
- }
-
/**
* Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
* I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
@@ -128,6 +95,39 @@ public final class ModuleExports implements Cloneable, Node {
}
}
+ /**
+ * Gets the flags for this ModuleExports.
+ * @return the exportsFlags
+ * @since 6.10.0
+ */
+ public int getExportsFlags() {
+ return exportsFlags;
+ }
+
+ /**
+ * Gets the exported package name.
+ * @param constantPool the constant pool from the ClassFile
+ * @return the exported package name
+ * @since 6.10.0
+ */
+ public String getPackageName(final ConstantPool constantPool) {
+ return constantPool.constantToString(exportsIndex, Const.CONSTANT_Package);
+ }
+
+ /**
+ * Gets an array of module names for this ModuleExports.
+ * @param constantPool Array of constants usually obtained from the ClassFile object
+ * @return array of module names following 'exports to'
+ * @since 6.10.0
+ */
+ public String[] getToModuleNames(final ConstantPool constantPool) {
+ final String[] toModuleNames = new String[exportsToCount];
+ for (int i = 0; i < exportsToCount; i++) {
+ toModuleNames[i] = getToModuleNameAtIndex(constantPool, exportsToIndex[i]);
+ }
+ return toModuleNames;
+ }
+
/**
* @return String representation
*/
diff --git a/src/main/java/org/apache/bcel/classfile/ModuleOpens.java b/src/main/java/org/apache/bcel/classfile/ModuleOpens.java
index f8da77c7..c3b916eb 100644
--- a/src/main/java/org/apache/bcel/classfile/ModuleOpens.java
+++ b/src/main/java/org/apache/bcel/classfile/ModuleOpens.java
@@ -32,9 +32,13 @@ import org.apache.bcel.Const;
*/
public final class ModuleOpens implements Cloneable, Node {
+ private static String getToModuleNameAtIndex(final ConstantPool constantPool, final int index) {
+ return constantPool.getConstantString(index, Const.CONSTANT_Module);
+ }
private final int opensIndex; // points to CONSTANT_Package_info
private final int opensFlags;
private final int opensToCount;
+
private final int[] opensToIndex; // points to CONSTANT_Module_info
/**
@@ -53,43 +57,6 @@ public final class ModuleOpens implements Cloneable, Node {
}
}
- /**
- * Gets the flags for this ModuleOpens.
- * @return the opensFlags
- * @since 6.10.0
- */
- public int getOpensFlags() {
- return opensFlags;
- }
-
- /**
- * Gets an array of module names for this ModuleOpens.
- * @param constantPool Array of constants usually obtained from the ClassFile object
- * @return array of module names following 'opens to'
- * @since 6.10.0
- */
- public String[] getToModuleNames(final ConstantPool constantPool) {
- final String[] toModuleNames = new String[opensToCount];
- for (int i = 0; i < opensToCount; i++) {
- toModuleNames[i] = getToModuleNameAtIndex(constantPool, opensToIndex[i]);
- }
- return toModuleNames;
- }
-
- private static String getToModuleNameAtIndex(final ConstantPool constantPool, final int index) {
- return constantPool.getConstantString(index, Const.CONSTANT_Module);
- }
-
- /**
- * Gets the opened package name.
- * @param constantPool the constant pool from the ClassFile
- * @return the opened package name
- * @since 6.10.0
- */
- public String getPackageName(final ConstantPool constantPool) {
- return constantPool.constantToString(opensIndex, Const.CONSTANT_Package);
- }
-
/**
* Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
* I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
@@ -128,6 +95,39 @@ public final class ModuleOpens implements Cloneable, Node {
}
}
+ /**
+ * Gets the flags for this ModuleOpens.
+ * @return the opensFlags
+ * @since 6.10.0
+ */
+ public int getOpensFlags() {
+ return opensFlags;
+ }
+
+ /**
+ * Gets the opened package name.
+ * @param constantPool the constant pool from the ClassFile
+ * @return the opened package name
+ * @since 6.10.0
+ */
+ public String getPackageName(final ConstantPool constantPool) {
+ return constantPool.constantToString(opensIndex, Const.CONSTANT_Package);
+ }
+
+ /**
+ * Gets an array of module names for this ModuleOpens.
+ * @param constantPool Array of constants usually obtained from the ClassFile object
+ * @return array of module names following 'opens to'
+ * @since 6.10.0
+ */
+ public String[] getToModuleNames(final ConstantPool constantPool) {
+ final String[] toModuleNames = new String[opensToCount];
+ for (int i = 0; i < opensToCount; i++) {
+ toModuleNames[i] = getToModuleNameAtIndex(constantPool, opensToIndex[i]);
+ }
+ return toModuleNames;
+ }
+
/**
* @return String representation
*/
diff --git a/src/main/java/org/apache/bcel/classfile/ModuleProvides.java b/src/main/java/org/apache/bcel/classfile/ModuleProvides.java
index 8c88f170..108b5dc6 100644
--- a/src/main/java/org/apache/bcel/classfile/ModuleProvides.java
+++ b/src/main/java/org/apache/bcel/classfile/ModuleProvides.java
@@ -32,8 +32,16 @@ import org.apache.bcel.Const;
*/
public final class ModuleProvides implements Cloneable, Node {
+ private static String getImplementationClassNameAtIndex(final ConstantPool constantPool, final int index, final boolean compactClassName) {
+ final String className = constantPool.getConstantString(index, Const.CONSTANT_Class);
+ if (compactClassName) {
+ return Utility.compactClassName(className, false);
+ }
+ return className;
+ }
private final int providesIndex; // points to CONSTANT_Class_info
private final int providesWithCount;
+
private final int[] providesWithIndex; // points to CONSTANT_Class_info
/**
@@ -51,39 +59,6 @@ public final class ModuleProvides implements Cloneable, Node {
}
}
- /**
- * Gets the array of implementation class names for this ModuleProvides.
- * @param constantPool Array of constants usually obtained from the ClassFile object
- * @param compactClassName false for original constant pool value, true to replace '/' with '.'
- * @return array of implementation class names
- * @since 6.10.0
- */
- public String[] getImplementationClassNames(final ConstantPool constantPool, final boolean compactClassName) {
- final String[] implementationClassNames = new String[providesWithCount];
- for (int i = 0; i < providesWithCount; i++) {
- implementationClassNames[i] = getImplementationClassNameAtIndex(constantPool, providesWithIndex[i], compactClassName);
- }
- return implementationClassNames;
- }
-
- private static String getImplementationClassNameAtIndex(final ConstantPool constantPool, final int index, final boolean compactClassName) {
- final String className = constantPool.getConstantString(index, Const.CONSTANT_Class);
- if (compactClassName) {
- return Utility.compactClassName(className, false);
- }
- return className;
- }
-
- /**
- * Gets the interface name for this ModuleProvides.
- * @param constantPool Array of constants usually obtained from the ClassFile object
- * @return interface name
- * @since 6.10.0
- */
- public String getInterfaceName(final ConstantPool constantPool) {
- return constantPool.constantToString(providesIndex, Const.CONSTANT_Class);
- }
-
/**
* Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
* I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
@@ -121,6 +96,31 @@ public final class ModuleProvides implements Cloneable, Node {
}
}
+ /**
+ * Gets the array of implementation class names for this ModuleProvides.
+ * @param constantPool Array of constants usually obtained from the ClassFile object
+ * @param compactClassName false for original constant pool value, true to replace '/' with '.'
+ * @return array of implementation class names
+ * @since 6.10.0
+ */
+ public String[] getImplementationClassNames(final ConstantPool constantPool, final boolean compactClassName) {
+ final String[] implementationClassNames = new String[providesWithCount];
+ for (int i = 0; i < providesWithCount; i++) {
+ implementationClassNames[i] = getImplementationClassNameAtIndex(constantPool, providesWithIndex[i], compactClassName);
+ }
+ return implementationClassNames;
+ }
+
+ /**
+ * Gets the interface name for this ModuleProvides.
+ * @param constantPool Array of constants usually obtained from the ClassFile object
+ * @return interface name
+ * @since 6.10.0
+ */
+ public String getInterfaceName(final ConstantPool constantPool) {
+ return constantPool.constantToString(providesIndex, Const.CONSTANT_Class);
+ }
+
/**
* @return String representation
*/
diff --git a/src/main/java/org/apache/bcel/classfile/ModuleRequires.java b/src/main/java/org/apache/bcel/classfile/ModuleRequires.java
index 678b0843..5c97e70c 100644
--- a/src/main/java/org/apache/bcel/classfile/ModuleRequires.java
+++ b/src/main/java/org/apache/bcel/classfile/ModuleRequires.java
@@ -48,35 +48,6 @@ public final class ModuleRequires implements Cloneable, Node {
requiresVersionIndex = file.readUnsignedShort();
}
- /**
- * Gets the flags for this ModuleRequires.
- * @return the requiresFlags
- * @since 6.10.0
- */
- public int getRequiresFlags() {
- return requiresFlags;
- }
-
- /**
- * Gets the required version from the constant pool.
- * @param constantPool Array of constants usually obtained from the ClassFile object
- * @return required version, "0" if version index is 0.
- * @since 6.10.0
- */
- public String getVersion(final ConstantPool constantPool) {
- return requiresVersionIndex == 0 ? "0" : constantPool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8);
- }
-
- /**
- * Gets the module name from the constant pool.
- * @param constantPool Array of constants usually obtained from the ClassFile object
- * @return module name
- * @since 6.10.0
- */
- public String getModuleName(final ConstantPool constantPool) {
- return constantPool.constantToString(requiresIndex, Const.CONSTANT_Module);
- }
-
/**
* Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
* I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
@@ -112,6 +83,35 @@ public final class ModuleRequires implements Cloneable, Node {
file.writeShort(requiresVersionIndex);
}
+ /**
+ * Gets the module name from the constant pool.
+ * @param constantPool Array of constants usually obtained from the ClassFile object
+ * @return module name
+ * @since 6.10.0
+ */
+ public String getModuleName(final ConstantPool constantPool) {
+ return constantPool.constantToString(requiresIndex, Const.CONSTANT_Module);
+ }
+
+ /**
+ * Gets the flags for this ModuleRequires.
+ * @return the requiresFlags
+ * @since 6.10.0
+ */
+ public int getRequiresFlags() {
+ return requiresFlags;
+ }
+
+ /**
+ * Gets the required version from the constant pool.
+ * @param constantPool Array of constants usually obtained from the ClassFile object
+ * @return required version, "0" if version index is 0.
+ * @since 6.10.0
+ */
+ public String getVersion(final ConstantPool constantPool) {
+ return requiresVersionIndex == 0 ? "0" : constantPool.getConstantString(requiresVersionIndex, Const.CONSTANT_Utf8);
+ }
+
/**
* @return String representation
*/
diff --git a/src/test/java/org/apache/bcel/AnonymousClassTestCase.java b/src/test/java/org/apache/bcel/AnonymousClassTestCase.java
index ed6f0dd7..b6420642 100644
--- a/src/test/java/org/apache/bcel/AnonymousClassTestCase.java
+++ b/src/test/java/org/apache/bcel/AnonymousClassTestCase.java
@@ -43,13 +43,6 @@ public class AnonymousClassTestCase extends AbstractTestCase {
assertTrue(clazz.isNested(), "regular inner classes are nested");
}
- @Test
- public void testRegularClassIsNotAnonymous() throws ClassNotFoundException {
- final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.AnonymousClassTest");
- assertFalse(clazz.isAnonymous(), "regular outer classes are not anonymous");
- assertFalse(clazz.isNested(), "regular outer classes are not nested");
- }
-
@Test
public void testRegularClassInnerClasses() throws ClassNotFoundException {
final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.AnonymousClassTest");
@@ -59,6 +52,13 @@ public class AnonymousClassTestCase extends AbstractTestCase {
assertNull(Repository.lookupClass(EmptyClass.class).getAttribute(Const.ATTR_INNER_CLASSES));
}
+ @Test
+ public void testRegularClassIsNotAnonymous() throws ClassNotFoundException {
+ final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.AnonymousClassTest");
+ assertFalse(clazz.isAnonymous(), "regular outer classes are not anonymous");
+ assertFalse(clazz.isNested(), "regular outer classes are not nested");
+ }
+
@Test
public void testStaticInnerClassIsNotAnonymous() throws ClassNotFoundException {
final JavaClass clazz = getTestJavaClass(PACKAGE_BASE_NAME + ".data.AnonymousClassTest$Y");
diff --git a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java
index 6855069e..7dce3b65 100644
--- a/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java
+++ b/src/test/java/org/apache/bcel/LocalVariableTypeTableTestCase.java
@@ -132,22 +132,6 @@ public class LocalVariableTypeTableTestCase extends AbstractTestCase {
return createPrintln(methodGen.getConstantPool(), instruction);
}
- @Test
- public void testWithGenericArguement() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
- final String targetClass = PACKAGE_BASE_NAME + ".data.SimpleClassHasMethodIncludeGenericArgument";
- final TestClassLoader loader = new TestClassLoader(getClass().getClassLoader());
- final Class<?> cls = loader.findClass(targetClass, getBytesFromClass(targetClass));
-
- java.lang.reflect.Method method = cls.getDeclaredMethod("a", String.class, List.class);
- method.invoke(null, "a1", new LinkedList<>());
- method = cls.getDeclaredMethod("b", String.class, List.class);
- method.invoke(null, "b1", new LinkedList<>());
- method = cls.getDeclaredMethod("c", String.class, String.class);
- method.invoke(null, "c1", "c2");
- method = cls.getDeclaredMethod("d", List.class, String.class);
- method.invoke(null, new LinkedList<>(), "d2");
- }
-
@Test
public void testGetLocalVariableTypeTable() throws ClassNotFoundException, NoSuchMethodException, SecurityException {
final JavaClass testJavaClass = getTestJavaClass("org/apache/commons/lang3/function/TriFunction");
@@ -163,4 +147,20 @@ public class LocalVariableTypeTableTestCase extends AbstractTestCase {
}
assertNull(Repository.lookupClass(Object.class).getMethod(Object.class.getMethod("toString")).getLocalVariableTypeTable());
}
+
+ @Test
+ public void testWithGenericArguement() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+ final String targetClass = PACKAGE_BASE_NAME + ".data.SimpleClassHasMethodIncludeGenericArgument";
+ final TestClassLoader loader = new TestClassLoader(getClass().getClassLoader());
+ final Class<?> cls = loader.findClass(targetClass, getBytesFromClass(targetClass));
+
+ java.lang.reflect.Method method = cls.getDeclaredMethod("a", String.class, List.class);
+ method.invoke(null, "a1", new LinkedList<>());
+ method = cls.getDeclaredMethod("b", String.class, List.class);
+ method.invoke(null, "b1", new LinkedList<>());
+ method = cls.getDeclaredMethod("c", String.class, String.class);
+ method.invoke(null, "c1", "c2");
+ method = cls.getDeclaredMethod("d", List.class, String.class);
+ method.invoke(null, new LinkedList<>(), "d2");
+ }
}