[lworld] RFR: 8280194: Abstract classes that allow value subclasses should be marked ACC_PERMITS_VALUE (0x0040) [v2]

Srikanth Adayapalam sadayapalam at openjdk.java.net
Tue Feb 1 11:33:23 UTC 2022


On Tue, 1 Feb 2022 11:04:48 GMT, Aggelos Biboudis <duke at openjdk.java.net> wrote:

> I was playing around to understand this generated test:
> 
> ```
> public class OuterClass {
>  static void method() {abstract class Local { class A0{}
> abstract class A1{}
> final class A2{}
> };}
> }
> ```
> 
> Why do we get the following for an inner class that is abstract,
> 
> ```
> [ASSERT] : inner_class_access_flags 1Local
> Expected: [ACC_ABSTRACT],
>      Got: [ACC_ABSTRACT, 0x40]
> ```
> 
> while `abstract class A8` in `PermitsValueTest.java` does not emit `ACC_PERMITS_VALUE`?

Class A8 in PermitsValue is an inner class that has an enclosing instance. Enclosing instance means the class will have an instance field to store the outer this and also its constructor will receive an argument - ie it cannot be a no-arg constructor only. (You may want to see the class files generated to understand the synthetic fields and constructor args that represent the outer this for an inner class with an enclosing instance) 

> 
> nitpick (and possibly not addressed yet): `Modifiers:getString()` doesn't return the name for `ACC_PERMITS_VALUE` yet. Do we need to address this in this PR? possibly not

Oops - Yes I will raise a follow up defect.

-------------

PR: https://git.openjdk.java.net/valhalla/pull/622



More information about the valhalla-dev mailing list