Skip to content
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

8269113: Javac throws when compiling switch (null) #4679

Closed
wants to merge 1 commit into from

Conversation

lgxbslgx
Copy link
Member

@lgxbslgx lgxbslgx commented Jul 4, 2021

Hi all,

When we use switch(null) in the source code, the type of the selector is BottomType.
So the statement Type seltype = selector.type; of the method TransPatterns::handleSwitch will get a BottomType.
Then compiler mistakenly uses this BottomType to construct a new VarSymbol.

            VarSymbol temp = new VarSymbol(Flags.SYNTHETIC,
                    names.fromString("selector" + tree.pos + target.syntheticNameChar() + "temp"),
                    seltype,     // <--------here is a BottomType
                    currentMethodSym);

At last, when the compiler uses the new VarSymbol temp to construct a new JCVariableDecl(the code shown as below), it crashes at the method TreeMaker::Type because the method TreeMaker::Type can't handle the type BottomType.

statements.append(make.at(tree.pos).VarDef(temp, !hasNullCase ? attr.makeNullCheck(selector)
                                                                          : selector));

This patch changes the type from BottomType to syms.objectType and adds the corresponding test.
Thanks for taking the time to review.

Best Regards,
-- Guoxiong


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8269113: Javac throws when compiling switch (null)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4679/head:pull/4679
$ git checkout pull/4679

Update a local copy of the PR:
$ git checkout pull/4679
$ git pull https://git.openjdk.java.net/jdk pull/4679/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4679

View PR using the GUI difftool:
$ git pr show -t 4679

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4679.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 4, 2021

👋 Welcome back gli! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 4, 2021
@openjdk
Copy link

openjdk bot commented Jul 4, 2021

@lgxbslgx The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Jul 4, 2021
@mlbridge
Copy link

mlbridge bot commented Jul 4, 2021

Webrevs

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

Looks good to me. Might make sense to submit against openjdk/jdk17 and integrate there?

@openjdk
Copy link

openjdk bot commented Jul 7, 2021

@lgxbslgx This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8269113: Javac throws when compiling switch (null)

Reviewed-by: jlahoda

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 47 new commits pushed to the master branch:

  • d1cecaa: 8269481: SctpMultiChannel never releases own file descriptor
  • 2209e3e: 8270027: ProblemList jdk/jfr/event/oldobject/TestObjectSize.java on macOS-x64
  • 2dc5486: 8267303: Replace MinObjectAlignmentSize usages for non-Java heap objects
  • 3586a23: 8268635: Corrupt oop in ClassLoaderData
  • bffb1a7: 8269923: runtime/jni/checked/TestPrimitiveArrayCriticalWithBadParam.java failed with "FATAL ERROR in native method: Primitive type array expected but not received for JNI array operation"
  • 77a5b7b: 8269761: idea.sh missing .exe suffix when invoking javac on WSL
  • 248aa50: 8269294: Verify_before/after_young_collection should execute all verification
  • 18b80c7: 8269908: Move MemoryService::track_memory_usage call into G1MonitoringScope
  • a685011: 8269022: Put evacuation failure string directly into gc=info log message
  • 72530ef: 8269574: C2: Avoid redundant uncommon traps in GraphKit::builtin_throw() for JVMTI exception events
  • ... and 37 more: https://git.openjdk.java.net/jdk/compare/17f53f2f9c5928395eff9186160924e9a8e9a794...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 7, 2021
@lgxbslgx
Copy link
Member Author

lgxbslgx commented Jul 7, 2021

@lahodaj thanks for your review. I will move this patch to JDK 17 later.

@lahodaj
Copy link
Contributor

lahodaj commented Jul 7, 2021

I am sorry, but it may not be so simple. I apologize for that, I need to do some more investigations, sorry.

@lgxbslgx
Copy link
Member Author

lgxbslgx commented Jul 7, 2021

Never mind. I will continue to contact or assist you in this PR. If the final patch is not large, it could be moved to JDK 17 at last.

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 4, 2021

@lgxbslgx This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 1, 2021

@lgxbslgx This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review
2 participants