|
If the enclosing class of a method is sealed and has only final
subclasses, then the method is effectively final in the sealed class if
none of the subclasses overrides it. This makes it possible to inline
more methods without explicitly marking them final.
Note that the test doesn't fail before this patch due to SI-6142,
a bug in the optimizer, but here's a bytecode diff to prove it:
@@ -16,8 +16,10 @@ public final class Test$ {
Code:
: getstatic // Field Foo$.MODULE$:LFoo$;
: invokevirtual // Method Foo$.mkFoo:()LFoo;
+: pop
: bipush
-: invokevirtual // Method Foo.bar:(I)I
+: iconst_1
+: iadd
: ireturn
And the test in neg, which is manually made to fail due to the absence
of inline warnings, correctly refuses to inline the methods.
Review by @dragos.
|