In this piece of code, why the compiler is not able to reference the method that has varargs argument from static context. JDK 17 is complaining Cannot make a static reference to the non-static method doSomething(int, int) . Is this a bug or another feature I am not aware of. JDK 8 and JDK 11 dont complain about it! Answer
Tag: language-lawyer
Why compiler cannot infer generic types of the inner class in Java?
When the above code snippet is compiled, it leads to Compile-Time error saying “incompatible types: cannot infer type arguments for A.InnerA<>. It seems to me that the Compiler should be able to infer the types to be InnerA<String>. Why is it not able to do so? It would be helpful if someone could explain how it works behind the scene.
Why is `getDeclaredAnnotations()` returning an empty list when an annotation is present?
The Javadocs entry for getDeclaredAnnotations say the following: Returns annotations that are directly present on this element. This method ignores inherited annotations. If there are no annotations directly present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the