8000 Add JDK 9 constant types to the ClassfileParser by eed3si9n · Pull Request #8289 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Add JDK 9 constant types to the ClassfileParser #8289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2019

Conversation

eed3si9n
Copy link
Member
@eed3si9n eed3si9n commented Jul 31, 2019

Fixes scala/bug#11635

Occasionally the compiler tries to parse the class files from the classpath. This happens, for example, during scaladoc comment referencing a class name java.time.Instant. This would cause error in JDK11 because it includes an unknown constant pool tag 19 (CONSTANT_Module). This updates the parser to skip it over.

Fixes scala/bug#11635

Occasionally the compiler tries to parse the class files from the classpath. This happens, for example, during scaladoc comment referencing a class name `java.time.Instant`. This would cause error in JDK11 because it includes an unknown constant pool tag 9 (CONSTANT_Module). This updates the parser to skip it over.
@eed3si9n eed3si9n requested review from retronym and SethTisue July 31, 2019 18:23
@scala-jenkins scala-jenkins added this to the 2.12.10 milestone Jul 31, 2019
@adriaanm adriaanm modified the milestones: 2.12.10, 2.12.9 Jul 31, 2019
@eed3si9n eed3si9n mentioned this pull request Jul 31, 2019
58 tasks
Copy link
Member
@lrytz lrytz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for 2.12.9

@eed3si9n eed3si9n merged commit 87d43d0 into scala:2.12.x Jul 31, 2019
@eed3si9n eed3si9n deleted the wip/constantpool branch July 31, 2019 23:23
@smarter
Copy link
Member
smarter commented Aug 3, 2019

According to the JVMS:

A CONSTANT_Module_info structure is permitted only in the constant pool of a class file that declares a module, that is, a ClassFile structure where the access_flags item has the ACC_MODULE flag set. In all other class files, a CONSTANT_Module_info structure is illegal.

(same for CONSTANT_PACKAGE). And classfiles with ACC_MODULE set correspond to module-info.class files, which the Scala compiler should never attempt to read since it doesn't understand Java 9 modules (at least until scala/scala-dev#529 is fixed).

The crash here means that the ClassfileParser is in fact reading these module-info classfiles, skipping over these constants may mask the problem, but something is still wrong here, it might not matter in practice, but it might make the compiler hallucinate classes called module-info in Java packages, or crash in other ways. The right thing to do is to change the ClassfileParser to skip over classfiles with ACC_MODULE set.

@SethTisue SethTisue mentioned this pull request Aug 3, 2019
1 task
@SethTisue
Copy link
Member

@retronym wdyt, is this sufficient for 2.12.9, or should we aim higher?

@retronym
Copy link
Member
retronym commented Aug 5, 2019

This is okay for now.

When we pick up https://github.com/scala/scala/pull/7218/files#diff-80bc15dacd4ac157908b9e98551ea58aR174 again, we'll exclude this module-info.class when populating ClassSymbols in a package (it should be excluded because - is not a valid character in a JVM class name.

@SethTisue SethTisue added the release-notes worth highlighting in next release notes label Aug 5, 2019
Shadowfiend added a commit to hacklanta/lift-formality that referenced this pull request Sep 22, 2019
Chiefly, this fixes an issue where the doc task would fail with Lift
3.3.0 and Scala <2.12.9, because Lift 3.3.0 was compiled with JDK 9 and
the doc compiler pre-2.12.9 had issues with certain constants from JDK 9
(see scala/bug#11635 and scala/scala#8289).
@nevillelyh
Copy link

We still maintain 2.11.12 cross builds and are affected by it, is there a workaround without reverting the offending dependencies?

@SethTisue
Copy link
Member
SethTisue commented Dec 11, 2019

whether there is a workaround might depend on what context you're hitting this in. is it during Scaladoc generation, or somewhere else?

separately, it's not exactly a "workaround", but you (or someone) could submit a 2.11.x backport of this PR, for inclusion in a possible eventual 2.11.13 release (no such release is planned, but if one does happen, you wouldn't want this change to miss the boat). if the PR is merged, then a Scala nightly would be published that you could use in your crossbuild. (caveat: the nightly builds aren't published to Maven Central and aren't guaranteed to exist indefinitely, though in practice they are re-create-able and aren't likely to disappear in the first place)

@nevillelyh
Copy link

Yeah it failed in ++2.11.12 doc and I worked around it by making doc a no-op for 2.11.
spotify/scio@985860c

Submitted #8595 backport. A few libs (notably Spark) may have to support 2.11 for a while so it'd be nice to have a 2.11.13 release eventually :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants
0