Fix tests broken by D8's handling of class retention annotations

A recent change to the dexer (see b/130028992) caused it to discard
class retention annotations from the generated dex code. That broke the
testRetentionPolicy_targetSdkVersion_23 test in the
libcore.j.l.reflect.annotations.AnnotationsTest class which was testing
to ensure that class retention annotations were visible to APKs that
target <= 23.

This change extracts the annotations and annotated classes used by the
affected test into their own JAR that is built using the --intermediate
option which prevents the class retention annotations from being
discarded. That JAR is then included in core-tests as a resource. The
retention policy tests extract the resource into its own file, creates
a PathClassLoader for it and then loads the test classes and
annotations from there.

Rather than extract the resource and create the PathClassLoader for
each test this uses JUnit 4 mechanisms to extract the resource once for
the whole class. The retention policy test methods were extracted into
their own class to minimize the change from switching to JUnit 4 and to
minimize the lifespan of the PathClassLoader.

Bug: 132100102
Test: atest \
    CtsLibcoreTestCases:libcore.java.lang.reflect.annotations.RetentionPolicyTest \
    CtsLibcoreTestCases:libcore.java.lang.reflect.annotations.AnnotationsTest
Change-Id: I67d46b9094d2da94c9cb02da9f0b2c619d0b5cdb
8 files changed