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

[SPARK-27121][REPL] Resolve Scala compiler failure for Java 9+ in REPL #24239

Closed
wants to merge 2 commits into from

Conversation

srowen
Copy link
Member

@srowen srowen commented Mar 29, 2019

What changes were proposed in this pull request?

Avoid trying to extract the classpath of the environment from a URLClassLoader in Java 11, as the default classloader isn't one. Use java.class.path instead.

How was this patch tested?

Existing tests, manually tested under Java 11.

@srowen srowen self-assigned this Mar 29, 2019
val classpath = paths.map(new File(_).getAbsolutePath).mkString(File.pathSeparator)
System.setProperty(CONF_EXECUTOR_CLASSPATH, classpath)
classpath
case _ => System.getProperty("java.class.path")
Copy link
Member Author

Choose a reason for hiding this comment

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

@squito this is your suggestion. I wonder why we don't just use this in all cases, Java 11 or no?

Copy link
Contributor

Choose a reason for hiding this comment

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

the only reason I can think of is the same reason I thought your change was better -- if somebody directly modifies the class path from within the JVM, then it won't show up in this system property.

But OTOH, this is our test code, so we control what's happening to the classpath, and it might as well be the same in java 11 and java 8 -- so I think this is fine.

@SparkQA
Copy link

SparkQA commented Mar 29, 2019

Test build #104074 has finished for PR 24239 at commit a90cbde.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

val classpath = paths.map(new File(_).getAbsolutePath).mkString(File.pathSeparator)
System.setProperty(CONF_EXECUTOR_CLASSPATH, classpath)
classpath
case _ => System.getProperty("java.class.path")
Copy link
Contributor

Choose a reason for hiding this comment

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

the only reason I can think of is the same reason I thought your change was better -- if somebody directly modifies the class path from within the JVM, then it won't show up in this system property.

But OTOH, this is our test code, so we control what's happening to the classpath, and it might as well be the same in java 11 and java 8 -- so I think this is fine.

System.clearProperty(CONF_EXECUTOR_CLASSPATH)
} else {
System.setProperty(CONF_EXECUTOR_CLASSPATH, oldExecutorClasspath)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand your changes to the handling of CONF_EXECUTOR_CLASSPATH. The old code saved the previous value, modified it, ran the tests, then restored the original value (which probably should have been in a finally). But it seems you're just resetting it to the same value it already has?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is my error, let me fix that. That behavior should be retained.

@squito
Copy link
Contributor

squito commented Mar 29, 2019

btw, how are you running tests? My approach has been to build everything with jdk8, switch to jdk11 and then run just the scalatest plugin (build/mvn scalatest:test). I found that if just ran build/mvn test with jdk11, it decided to recompile everything. I'm assuming we still want to have the binaries built using jdk8. Just setting -target 1.8 isn't enough to ensure that the binaries are actually compatible with 1.8, so I figured that's the best way to test.

@srowen
Copy link
Member Author

srowen commented Mar 29, 2019

I have been using Java 8 to compile, and Java 11 to test, yes. I set JAVA_HOME and change what java points to to switch. I am using Maven to compile and then run tests. Yeah you raise a good point, sometimes it thinks it needs to recompile, although I think in my case it will be using Java 8 anyway as javac always points to Java 8.

Yeah I'd want to be pretty sure that's valid before declaring everything working for Java 11, but it is letting me turn up Java 11-specific issues. That is, I don't expect that there's an issue that's hiding because somehow a class was compiled by Java 11, but it's possible. I expect the problems to be with the JDK classes and dependencies.

I think we're going to call this support 'experimental' for 3.0 in any event as we may not ultimately resolve the Hive problems.

@squito
Copy link
Contributor

squito commented Mar 29, 2019

At some point, I discovered that just setting JAVA_HOME wasn't enough -- I also had to make sure the right version of java was first on the path. I forget whether this was with sbt or mvn ... and maybe it was actually something else I was doing wrong and I misattributed the problem. But I wanted to mention it at least to you if things ever don't seem to be behaving as you expect

@SparkQA
Copy link

SparkQA commented Mar 29, 2019

Test build #104084 has finished for PR 24239 at commit fb5ed12.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member Author

srowen commented Mar 29, 2019

Yeah, I have to use update-alternatives to get the right java to be used. I'm pretty confident this mostly works, as it definitely causes Java 11-related failures that don't appear in Java 8.

@srowen
Copy link
Member Author

srowen commented Mar 29, 2019

(FWIW this updated change also still passes on Java 11)

Copy link
Contributor

@squito squito left a comment

Choose a reason for hiding this comment

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

lgtm

@srowen
Copy link
Member Author

srowen commented Mar 30, 2019

Merged to master. Let's see if the PR builder for Java 11 likes it now (because not sure it tests Hive)

@srowen srowen closed this in e6d8d0f Mar 30, 2019
@srowen srowen deleted the SPARK-27121.0 branch March 31, 2019 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants