Skip to content

SI-9359 Fix InnerClass entry flags for nested Java enums#4566

Merged
adriaanm merged 2 commits intoscala:2.11.xfrom
lrytz:t9359
Jun 22, 2015
Merged

SI-9359 Fix InnerClass entry flags for nested Java enums#4566
adriaanm merged 2 commits intoscala:2.11.xfrom
lrytz:t9359

Conversation

@lrytz
Copy link
Member

@lrytz lrytz commented Jun 19, 2015

The access flags in InnerClass entries for nested Java enums were
basically completely off.

A first step is to use the recently introduced backend method
javaClassfileFlags, which is now moved to BCodeAsmCommon.
See its doc for an explanation.

Then the flags of the enum class symbol were off. An enum is

When using the ClassfileParser:

  • ENUM was never added. I guess that's just an oversight.
  • ABSTRACT (together with SEALED) was always added. This is to
    enable exhaustiveness checking, see 3f7b8b5. This is a hack and we
    have to go through the class members in the backend to find out if
    the enum actually has the ACC_ABSTRACT flag or not.

When using the JavaParser:

  • FINAL was never added.
  • ABSTRACT was never added.

This commit fixes all of the above and tests cases (Java enum read
from the classfile and from source).

The access flags in InnerClass entries for nested Java enums were
basically completely off.

A first step is to use the recently introduced backend method
`javaClassfileFlags`, which is now moved to BCodeAsmCommon.
See its doc for an explanation.

Then the flags of the enum class symbol were off. An enum is
  - final if none of its values has a class body
  - abstract if it has an abstract method
(https://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.9)

When using the ClassfileParser:
  - ENUM was never added. I guess that's just an oversight.
  - ABSTRACT (together with SEALED) was always added. This is to
    enable exhaustiveness checking, see 3f7b8b5. This is a hack and we
    have to go through the class members in the backend to find out if
    the enum actually has the `ACC_ABSTRACT` flag or not.

When using the JavaParser:
  - FINAL was never added.
  - ABSTRACT was never added.

This commit fixes all of the above and tests cases (Java enum read
from the classfile and from source).
@scala-jenkins scala-jenkins added this to the 2.11.8 milestone Jun 19, 2015
@lrytz
Copy link
Member Author

lrytz commented Jun 19, 2015

Review by @adriaanm. I think this should not go in 2.11.7.

@adriaanm adriaanm modified the milestones: 2.11.8, 2.11.7 Jun 19, 2015
@adriaanm
Copy link
Contributor

ok, I reopened the milestone

@lrytz
Copy link
Member Author

lrytz commented Jun 19, 2015

you missed the "not" 😮

@adriaanm adriaanm modified the milestones: 2.11.8, 2.11.7 Jun 19, 2015
@adriaanm
Copy link
Contributor

not anymore :)

@adriaanm
Copy link
Contributor

thanks

@lrytz
Copy link
Member Author

lrytz commented Jun 20, 2015

@adriaanm @SethTisue I actually changed my mind, and I do think we should get this into 2.11.7. It fixes all failures of the -Ybackend:GenBCode nightly, and some of the failures look pretty bad:

java.lang.ClassFormatError: Illegal class modifiers in class scala/tools/nsc/interpreter/JavapClass$JavapTool7$JavapFileManager: 0x419
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)

@lrytz
Copy link
Member Author

lrytz commented Jun 20, 2015

Note that the above failure (Illegal class modifiers) would be a regression in 2.11.7, it's not there in 2.11.6. It was introduced when #4529 was merged.

@adriaanm adriaanm modified the milestones: 2.11.7, 2.11.8 Jun 20, 2015
@adriaanm
Copy link
Contributor

LGTM

adriaanm added a commit that referenced this pull request Jun 22, 2015
SI-9359 Fix InnerClass entry flags for nested Java enums
@adriaanm adriaanm merged commit 61fbcab into scala:2.11.x Jun 22, 2015
@lrytz
Copy link
Member Author

lrytz commented Jun 23, 2015

GenBCode build turned green.

@adriaanm
Copy link
Contributor

!! 🎆 !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants