> On 31 May 2016, at 14:17, [email protected] wrote:
> 
> Hi All,
> 
> Please see updated webrev 
> http://cr.openjdk.java.net/~srastogi/8147585/webrev.02/
> 

I meant do something like this:

  static class MethodsWithAnnotations {
    @LambdaWithParameter
    public void testAnnotationLambdaWithParameter() {
    }

    @LambdaWithoutParameter
    public void testAnnotationLambdaWithoutParameter() {
    }
  }

Then you don’t need to do:

  49             if(!method.getName().equals("testAnnotationWithLambda")) {



> On 5/31/2016 2:21 PM, Paul Sandoz wrote:
>>> On 31 May 2016, at 10:35, [email protected]
>>>  wrote:
>>> 
>>> Thanks Paul for comments.
>>> 
>>> Please see
>>> http://cr.openjdk.java.net/~srastogi/8147585/webrev.01/
>>> 
>>> 
>>> Now processing only public abstract methods of interface.
>>> 
>>> 
>> Thanks. It would be good to get some got feedback from those wiser than I in 
>> this regard.
>> 
>> Have you looked at the existing annotation-based tests to see if they test 
>> edge cases e.g. annotation classes generated with incorrect methods? that 
>> might give us some clues.
>> 
>   I saw existing annotation-based test, valid modifier for annotations, valid 
> method for annotation tests we are checking in javac code.
>   default, static, private modifier we are restricting at compile time so we 
> can not add test cases for this  (compilation will fail).
> 

We may be getting our wires crossed. I was wondering if there were some 
existing tests that generate annotation classes by directly producing byte code 
that would otherwise not be possible with javac. If there are it might give us 
some clues.

I was not suggesting as part of this fix you write some such tests.


> So only scenario i can add is for synthetic methods. ( according to my 
> assumption)
> In AnnotationType.java
> 
> public Method[] run() {
>      // Initialize memberTypes and defaultValues
>      return annotationClass.getDeclaredMethods();
>   }
> });
> 
> As here, calling getDeclaredMethods() on annotationclass and 
> getDeclaredMethods() doc says
> 
> https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredMethods--
> "Returns an array containing Method objects reflecting all the declared 
> methods of the class or interface represented by this Class object, including 
> public, protected, default (package) access, and private methods, but 
> excluding inherited methods."
> 
> Doc did not mention anything about synthetic methods so i am not sure this is 
> expected behavior or not.

A synthetic method is one that must one of public, protected, default (package) 
access, and private (i don’t actually know if synthetic methods are stricter in 
their scope).

But i think we are deviating off topic, which is the processing of declared 
methods by AnnotationType to build up the annotation property metadata.

I just want to be sure that skipping all non-public non-abstract methods when 
processing is not gonna cause issues. It seems obvious it should skip such 
methods, but it has not been implemented that way.

Perhaps this is just an oversight, i dunno, but sometimes things in a JDK are 
there for a reason, and it’s often hard to know. We can try making an offering 
to the Java gods and looking out for the eagle that flies straight and narrow 
to the right, or alternatively ask someone more expert in this area :-)

AFAICT from debugging a little in this area the additional information added by 
processing never gets exposed, so it’s just wasted space/time.

Paul.



> If yes, Could you please suggest how to add testcases to test synthetic 
> method?
> Shall I use ASM?
> 
> Regards,
> Shilp

Reply via email to