Skip to content

Commit

Permalink
Per Robert's advice
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-hammant committed Aug 27, 2021
1 parent 6408fe1 commit 0fd4b6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,8 @@ public void processClasses(Collection<JavaClass> classes, String outputPath) thr
StringBuilder content = new StringBuilder();
content.append(addConstructors(javaClass.getConstructors()));
content.append(addMethods(javaClass.getMethods()));
// TODO problem with inner classes
String fullyQualifiedName = javaClass.getFullyQualifiedName();

try {
makeEnhancer().enhance(new File(outputPath, fullyQualifiedName.replace('.', File.separatorChar) + ".class"), content);
} catch (FileNotFoundException e) {
// Maybe inner class - QDox changes fully-qualified-names for these
StringBuilder fullyQualifiedNameSB = new StringBuilder(fullyQualifiedName);
fullyQualifiedNameSB.setCharAt(fullyQualifiedName.lastIndexOf("."), '$');
makeEnhancer().enhance(new File(outputPath, fullyQualifiedNameSB.toString().replace('.', File.separatorChar) + ".class"), content);
}

makeEnhancer().enhance(new File(outputPath, javaClass.getBinaryName().replace('.', File.separatorChar) + ".class"), content);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
package com.thoughtworks.paranamer;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import java.lang.reflect.Constructor;
Expand Down Expand Up @@ -243,13 +244,14 @@ public void testRetrievesParameterNamesFromAConstructorInJar()
assertThatParameterNamesMatch("foo", asm.lookupParameterNames(ctor));
}

// JDK 16 - yup, you can ...
@Test
@Ignore
public void testRetrievesParameterNamesFromBootstrapClassLoader() throws SecurityException, NoSuchMethodException {
BytecodeReadingParanamer asm = new BytecodeReadingParanamer();
Constructor<?> ctor = Integer.class.getConstructor(int.class);
try {
asm.lookupParameterNames(ctor);
fail("Should not find names for classes loaded by the bootstrap class loader.");
assertEquals("value", asm.lookupParameterNames(ctor)[0]);
} catch(ParameterNamesNotFoundException ex) {
// ok
}
Expand Down

0 comments on commit 0fd4b6f

Please sign in to comment.