Improve TestCompiler and allow lookup based class defines

Update the `TestCompiler` so that classes can be defined using
a `Lookup`. This update allows package-private classes to be
accessed without needing a quite so unusual classloader setup.

The `@CompileWithTargetClassAccess` should be added to any
test that needs to use `Lookup` based defines. The test will
run with a completed forked classloader so not to pollute the
main classloader.

This commit also adds some useful additional APIs.

See gh-28120
This commit is contained in:
Phillip Webb
2022-04-13 16:48:13 -07:00
parent b3efdf3c2b
commit 4b82546b97
18 changed files with 622 additions and 60 deletions

View File

@@ -38,6 +38,9 @@
<suppress files="ResolvableType" checks="FinalClass"/>
<suppress files="[\\/]src[\\/]testFixtures[\\/]java[\\/].+" checks="IllegalImport" id="bannedJUnitJupiterImports"/>
<!-- spring-core-test -->
<suppress files="CompileWithTargetClassAccess" checks="IllegalImport" id="bannedJUnitJupiterImports" />
<!-- spring-expression -->
<suppress files="ExpressionException" checks="MutableException"/>
<suppress files="SpelMessage" checks="JavadocVariable|JavadocStyle"/>