JDK 13 RFR of JDK-8164819: Make javac's toString() on annotation objects consistent with core reflection

Jonathan Gibbons jonathan.gibbons at oracle.com
Tue Jun 4 18:33:06 UTC 2019


+1


On 06/04/2019 09:46 AM, Joe Darcy wrote:
> Thanks Jon.
>
> FYI, updated webrev at
>
>     http://cr.openjdk.java.net/~darcy/8164819.3/
>
> Diff of patches below. Typo in the AnnotationInvocationHandler.java 
> variable name corrected, ElementStructureTest test update courtesy 
> Jan, and small update to the HotSpot test ConstMethodTest.java to 
> accommodate the changed format.
>
> Thanks,
>
> -Joe
>
> > --- 
> old/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java 
> 2019-06-04 09:26:16.824947998 -0700
> > +++ 
> new/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java 
> 2019-06-04 09:26:16.497112000 -0700
> 45,46c45,55
> < @@ -228,7 +236,7 @@
> <              arrayBackets.append("[]");
> ---
> > @@ -221,14 +229,14 @@
> >       */
> >      private static String toSourceString(Class<?> clazz) {
> >          Class<?> finalComponent = clazz;
> > -        StringBuilder arrayBackets = new StringBuilder();
> > +        StringBuilder arrayBrackets = new StringBuilder();
> >
> >          while(finalComponent.isArray()) {
> >              finalComponent = finalComponent.getComponentType();
> > -            arrayBackets.append("[]");
> > +            arrayBrackets.append("[]");
> 50c59
> < +        return finalComponent.getName() + arrayBackets.toString() + 
> ".class";
> ---
> > +        return finalComponent.getName() + arrayBrackets.toString() 
> + ".class";
>
>
> < --- old/test/langtools/tools/javac/sym/ElementStructureTest.java 
> 2019-06-03 13:45:14.639762024 -0700
> < +++ new/test/langtools/tools/javac/sym/ElementStructureTest.java 
> 2019-06-03 13:45:14.319922012 -0700
> < @@ -23,6 +23,7 @@
> <
> <  /**
> <   * @test
> < + * @ignore
> <   * @bug 8072480 8203814
> <   * @summary Check the platform classpath contains the correct 
> elements.
> <   * @library /tools/lib
> ---
> > --- old/test/langtools/tools/javac/sym/ElementStructureTest.java 
> 2019-06-04 09:26:37.002853999 -0700
> > +++ new/test/langtools/tools/javac/sym/ElementStructureTest.java 
> 2019-06-04 09:26:36.683013999 -0700
> > @@ -1,5 +1,5 @@
> >  /*
> > - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All 
> rights reserved.
> > + * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All 
> rights reserved.
> >   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> >   *
> >   * This code is free software; you can redistribute it and/or 
> modify it
> > @@ -128,16 +128,16 @@
> >          (byte) 0xB7, (byte) 0x52, (byte) 0x0F, (byte) 0x68
> >      };
> >      static final byte[] hash7 = new byte[] {
> > -        (byte) 0x6B, (byte) 0xA2, (byte) 0xE9, (byte) 0x8E,
> > -        (byte) 0xE1, (byte) 0x8E, (byte) 0x60, (byte) 0xBE,
> > -        (byte) 0x54, (byte) 0xC4, (byte) 0x33, (byte) 0x3E,
> > -        (byte) 0x0C, (byte) 0x2D, (byte) 0x3A, (byte) 0x7C
> > + (byte) 0x3C, (byte) 0x03, (byte) 0xEA, (byte) 0x4A,
> > + (byte) 0x62, (byte) 0xD2, (byte) 0x18, (byte) 0xE5,
> > + (byte) 0xA5, (byte) 0xC2, (byte) 0xB7, (byte) 0x85,
> > + (byte) 0x90, (byte) 0xFA, (byte) 0x98, (byte) 0xCD
> >      };
> >      static final byte[] hash8 = new byte[] {
> > -        (byte) 0x44, (byte) 0x77, (byte) 0x6E, (byte) 0x52,
> > -        (byte) 0x2B, (byte) 0x16, (byte) 0xD3, (byte) 0x3C,
> > -        (byte) 0x78, (byte) 0x75, (byte) 0xF5, (byte) 0x0A,
> > -        (byte) 0x01, (byte) 0x24, (byte) 0xBD, (byte) 0x2A
> > + (byte) 0x0B, (byte) 0xEB, (byte) 0x16, (byte) 0xF5,
> > + (byte) 0x7F, (byte) 0xB0, (byte) 0x18, (byte) 0xF1,
> > + (byte) 0x78, (byte) 0x11, (byte) 0xED, (byte) 0x30,
> > + (byte) 0x19, (byte) 0x4D, (byte) 0xDE, (byte) 0x8A
> >      };
> >
> >      final static Map<String, byte[]> version2Hash = new HashMap<>();
>
> > --- old/test/hotspot/jtreg/runtime/8007320/ConstMethodTest.java 
> 2019-06-04 09:26:37.562573999 -0700
> > +++ new/test/hotspot/jtreg/runtime/8007320/ConstMethodTest.java 
> 2019-06-04 09:26:37.242733999 -0700
> > @@ -1,5 +1,5 @@
> >  /*
> > - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All 
> rights reserved.
> > + * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All 
> rights reserved.
> >   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> >   *
> >   * This code is free software; you can redistribute it and/or 
> modify it
> > @@ -122,8 +122,8 @@
> >                  equal(ann.length, 3);
> >                  Annotation foo = ann[0][0];
> >                  Annotation bar = ann[1][0];
> > -                equal(foo.toString(), "@Named(value=\"aName\")");
> > -                equal(bar.toString(), "@Named(value=\"bName\")");
> > +                equal(foo.toString(), "@Named(\"aName\")");
> > +                equal(bar.toString(), "@Named(\"bName\")");
> >                  check(foo.equals(foo));
> >                  check(bar.equals(bar));
> >                  check(! foo.equals(bar));
>
> On 6/3/2019 4:01 PM, Jonathan Gibbons wrote:
>>
>> OK, but with a typo to be fixed in the first file (ArrayBackets)
>>
>> "It would be nice" if we could share the test cases in the new 
>> AnnotationToStringTest with an equivalent test for javadoc, but I 
>> can't think of a clean way to do that (so far).
>>
>> -- Jon
>>



More information about the compiler-dev mailing list