Allow TestCompiler to load cglib generated classes

Update `TestCompiler` so that it can now load cglib generated classes.
This commit adds support to `DynamicJavaFileManager` so that it can
reference generated classes and adds a new lookup function to
`CompileWithTargetClassAccessClassLoader` to that it can load the
bytecode of generated classes directly.

See gh-29141

Co-authored-by: Phillip Webb <pwebb@vmware.com>
This commit is contained in:
Andy Wilkinson
2022-09-19 09:27:09 -07:00
committed by Phillip Webb
parent 5277b1dbf0
commit 7168141504
6 changed files with 103 additions and 69 deletions

View File

@@ -101,8 +101,8 @@ class DynamicJavaFileManagerTests {
Kind.CLASS, null);
this.fileManager.getJavaFileForOutput(this.location, "com.example.MyClass2",
Kind.CLASS, null);
assertThat(this.fileManager.getClassFiles().stream().map(ClassFile::getName))
.contains("com.example.MyClass1", "com.example.MyClass2");
assertThat(this.fileManager.getCompiledClasses()).containsKeys(
"com.example.MyClass1", "com.example.MyClass2");
}
@Test