modifiers of default methods

David Holmes david.holmes at oracle.com
Thu Oct 4 17:10:19 PDT 2012


On 4/10/2012 11:34 AM, Stephan Herrmann wrote:
> Using jdk1.8.0-lambda-8-b56 I can compile the following
>
> public interface I {
> 	strictfp synchronized void foo() default {}
> }

Interesting. I hadn't thought about this aspect of default methods. I 
can easily imagine people interpreting the above as meaning that the 
foo() method must always be synchronized and strictfp. And while 
synchronized is an implementation detail, strictfp could be seen as 
being part of the specification ...

David
-----

> public class C implements I {
> 	public static void main (String[] args) {
> 		System.out.println("Hi");
> 	}
> }
>
> but any attempt to run the resulting class files gives:
>
> Exception in thread "main" java.lang.ClassFormatError: Method foo in
> class I has illegal modifiers: 0x821
>
> Does the VM require bit AccDefaultMethod to be set (I haven't yet
> seen a specification of that flag), or is the VM simply not updated
> to accept the newly legal combination of modifiers?
>
> best,
> Stephan
>
>


More information about the lambda-dev mailing list