RFR: 8337302: Undefined type variable results in null [v4]

Chen Liang liach at openjdk.org
Fri Aug 16 04:48:50 UTC 2024


On Fri, 16 Aug 2024 03:27:27 GMT, Joe Darcy <darcy at openjdk.org> wrote:

>> Rafael Winterhalter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8337302: Fix copyright years.
>
> test/jdk/java/lang/reflect/Generics/TestMissingTypeVariable.java line 43:
> 
>> 41: public class TestMissingTypeVariable {
>> 42: 
>> 43:     public static void main(String[] args) throws Exception {
> 
> To make the test more understandable to casual readers, I suggest putting the corresponding source code, as much as possible, as a comment.

An alternative approach could be to write a package-private or nested class in the same file:

static class Generic<T> {
    T field;
}

// ...

var cf = ClassFile.of();
var generic = cf.parse(Path.of(System.getProperty("test.classes"), "TestMissingTypeVariable$Generic.class"));
var result = cf.transformClass(generic, ClassTransform.dropping(ce -> ce instanceof SignatureAttribute);
var missing = ByteCodeLoader.load("TestMissingTypeVariable$Generic", result);
// proceed


Would be more straightforward to readers.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20535#discussion_r1719294839


More information about the core-libs-dev mailing list