RFR(s): JDK-8205455: jdeprscan issues annotation processor warning regarding RELEASE_10

Jonathan Gibbons jonathan.gibbons at oracle.com
Tue Jun 26 00:07:33 UTC 2018


+1

On 06/25/2018 05:04 PM, Stuart Marks wrote:
>
> Hi Jon,
>
> Good point. It seems fairly unlikely for jdeprscan to be outright 
> broken by a model change, given that jdeprscan uses annotation 
> processing for class scanning, not source code analysis.
>
> I've posted an updated webrev here:
>
> http://cr.openjdk.java.net/~smarks/reviews/8205455/webrev.1/
>
> (previous patch posted as webrev.0 for completeness)
>
> s'marks
>
>
> On 6/25/18 3:35 PM, Jonathan Gibbons wrote:
>>
>> Stuart,
>>
>> This would be more future-proof if you did not use these lines:
>>
>>
>> - at SupportedSourceVersion(RELEASE_10)
>> + at SupportedSourceVersion(RELEASE_11)
>>
>> but instead provided an override definition like this, taken from 
>> test/langtools/tools/javac/lib/JavacTestingAbstractProcessor:
>>
>>      /**
>>       * Return the latest source version. Unless this method is
>>       * overridden, an {@code IllegalStateException} will be thrown if a
>>       * subclass has a {@code SupportedSourceVersion} annotation.
>>       */
>>      @Override
>>      public SourceVersion getSupportedSourceVersion() {
>>          SupportedSourceVersion ssv = this.getClass().getAnnotation(SupportedSourceVersion.class);
>>          if (ssv != null)
>>              throw new IllegalStateException("SupportedSourceVersion annotation not supported here.");
>>
>>          return SourceVersion.latest();
>>      }
>>
>> or, more simply
>>
>>      @Override
>>      public SourceVersion getSupportedSourceVersion() {
>>          return SourceVersion.latest();
>>      }
>>
>> On 6/25/18 3:28 PM, Stuart Marks wrote:
>>> Hi all,
>>>
>>> Please review this small changeset that updates one of jdeprscan's 
>>> annotation processors to RELEASE_11 in order to prevent warning 
>>> messages from being issued. This changeset also includes some 
>>> additional output lines so that the output of jdeprscan's 
>>> TestRelease.java test is more readable.
>>>
>>> Patch appended below.
>>>
>>> Bug:
>>>
>>> https://bugs.openjdk.java.net/browse/JDK-8205455
>>>
>>> Thanks,
>>>
>>> s'marks
>>>
>>>
>>> # HG changeset patch
>>> # User smarks
>>> # Date 1529965383 25200
>>> #      Mon Jun 25 15:23:03 2018 -0700
>>> # Node ID c243b75831dc8047173586c145a9086e38ebfd76
>>> # Parent  b85ca7757c381b7a5fe6ab4ad3a0e981541eff0e
>>> 8205455: jdeprscan issues annotation processor warning regarding 
>>> RELEASE_10
>>> Reviewed-by: XXX
>>>
>>> diff -r b85ca7757c38 -r c243b75831dc 
>>> src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java
>>> --- 
>>> a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java 
>>> Mon Jun 25 15:02:31 2018 -0700
>>> +++ 
>>> b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java 
>>> Mon Jun 25 15:23:03 2018 -0700
>>> @@ -1,5 +1,5 @@
>>>  /*
>>> - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All 
>>> rights reserved.
>>> + * Copyright (c) 2016, 2018, 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
>>> @@ -45,14 +45,14 @@
>>>  import javax.lang.model.element.TypeElement;
>>>  import javax.lang.model.util.Elements;
>>>
>>> -import static javax.lang.model.SourceVersion.RELEASE_10;
>>> +import static javax.lang.model.SourceVersion.RELEASE_11;
>>>  import javax.lang.model.element.Element;
>>>  import javax.lang.model.element.ElementKind;
>>>  import javax.lang.model.element.Modifier;
>>>  import javax.lang.model.element.PackageElement;
>>>  import javax.tools.Diagnostic;
>>>
>>> - at SupportedSourceVersion(RELEASE_10)
>>> + at SupportedSourceVersion(RELEASE_11)
>>>  @SupportedAnnotationTypes("*")
>>>  public class TraverseProc extends AbstractProcessor {
>>>      Elements elements;
>>> diff -r b85ca7757c38 -r c243b75831dc 
>>> test/langtools/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java
>>> --- 
>>> a/test/langtools/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java Mon 
>>> Jun 25 15:02:31 2018 -0700
>>> +++ 
>>> b/test/langtools/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java Mon 
>>> Jun 25 15:23:03 2018 -0700
>>> @@ -44,7 +44,10 @@
>>>
>>>  public class TestRelease {
>>>      static boolean invoke(String arg) {
>>> -        return Main.call(System.out, System.err, "--list", 
>>> "--release", arg);
>>> +        System.err.println(">>> invoking Main.call with arguments: 
>>> --list --release " + arg);
>>> +        boolean r = Main.call(System.out, System.err, "--list", 
>>> "--release", arg);
>>> +        System.err.println(">>> Main.call returned " + r);
>>> +        return r;
>>>      }
>>>
>>>      @Test
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180625/c160d2e8/attachment-0001.html>


More information about the compiler-dev mailing list