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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalac version 2.12.8 throws exception in unicode directory #11490

Open
mlekena opened this issue Apr 16, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@mlekena
Copy link

commented Apr 16, 2019

When in a directory path /Users/theko/Documents/code snippets/scala/unicode_test/饾敇饾敨饾敠饾敔饾敩饾敗饾敘, notice the 饾敇饾敨饾敠饾敔饾敩饾敗饾敘, scalac fails with the below stacktrace when calling -help or attempting to compile helloworld scala source.

scalac -help
Exception in thread "main" java.lang.ExceptionInInitializerError
	at scala.tools.util.PathResolver$Environment$.scalaExtDirs(PathResolver.scala:77)
	at scala.tools.util.PathResolver$Defaults$.scalaExtDirs(PathResolver.scala:127)
	at scala.tools.nsc.settings.StandardScalaSettings.$init$(StandardScalaSettings.scala:31)
	at scala.tools.nsc.settings.MutableSettings.<init>(MutableSettings.scala:28)
	at scala.tools.nsc.Settings.<init>(Settings.scala:19)
	at scala.tools.nsc.Driver.process(Driver.scala:53)
	at scala.tools.nsc.Driver.main(Driver.scala:80)
	at scala.tools.nsc.Main.main(Main.scala)
Caused by: java.lang.IllegalArgumentException: Error decoding percent encoded characters
	at java.base/sun.net.www.ParseUtil.decode(ParseUtil.java:209)
	at java.base/jdk.internal.loader.FileURLMapper.getPath(FileURLMapper.java:64)
	at java.base/jdk.internal.loader.FileURLMapper.exists(FileURLMapper.java:73)
	at java.base/jdk.internal.loader.URLClassPath$JarLoader.getJarFile(URLClassPath.java:802)
	at java.base/jdk.internal.loader.URLClassPath$JarLoader.access$900(URLClassPath.java:692)
	at java.base/jdk.internal.loader.URLClassPath$JarLoader$1.run(URLClassPath.java:751)
	at java.base/jdk.internal.loader.URLClassPath$JarLoader$1.run(URLClassPath.java:744)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/jdk.internal.loader.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:743)
	at java.base/jdk.internal.loader.URLClassPath$JarLoader.<init>(URLClassPath.java:718)
	at java.base/jdk.internal.loader.URLClassPath$3.run(URLClassPath.java:486)
	at java.base/jdk.internal.loader.URLClassPath$3.run(URLClassPath.java:469)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/jdk.internal.loader.URLClassPath.getLoader(URLClassPath.java:468)
	at java.base/jdk.internal.loader.URLClassPath.getLoader(URLClassPath.java:437)
	at java.base/jdk.internal.loader.URLClassPath.findResource(URLClassPath.java:280)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findResourceOnClassPath(BuiltinClassLoader.java:479)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findResource(BuiltinClassLoader.java:303)
	at java.base/java.lang.ClassLoader.getResource(ClassLoader.java:1393)
	at java.base/java.lang.ClassLoader.getSystemResource(ClassLoader.java:1658)
	at java.base/java.lang.ClassLoader.getSystemResourceAsStream(ClassLoader.java:1762)
	at java.base/java.lang.Class.getResourceAsStream(Class.java:2607)
	at scala.util.PropertiesTrait.scalaProps(Properties.scala:39)
	at scala.util.PropertiesTrait.scalaProps$(Properties.scala:37)
	at scala.tools.reflect.WrappedProperties$AccessControl$.scalaProps$lzycompute(WrappedProperties.scala:49)
	at scala.tools.reflect.WrappedProperties$AccessControl$.scalaProps(WrappedProperties.scala:49)
	at scala.util.PropertiesTrait.scalaPropOrNone(Properties.scala:71)
	at scala.util.PropertiesTrait.scalaPropOrNone$(Properties.scala:71)
	at scala.tools.reflect.WrappedProperties$AccessControl$.scalaPropOrNone(WrappedProperties.scala:49)
	at scala.util.PropertiesTrait.$init$(Properties.scala:83)
	at scala.tools.reflect.WrappedProperties$AccessControl$.<init>(WrappedProperties.scala:49)
	at scala.tools.reflect.WrappedProperties$AccessControl$.<clinit>(WrappedProperties.scala)
	... 8 more

Version details:
Scala compiler version 2.12.8 -- Copyright 2002-2018, LAMP/EPFL and Lightbend, Inc.
javac 10.0.1
Mac version 10.13.6 (17G5019)

To reproduce:
Create directory with folder named 饾敇饾敨饾敠饾敔饾敩饾敗饾敘 (copy this name)
cd into folder and then run scalac -help

@som-snytt

This comment has been minimized.

Copy link

commented Apr 16, 2019

Come to think of it, this now wins the award for shortest reproducer, with zero LOC.

@som-snytt

This comment has been minimized.

Copy link

commented Apr 21, 2019

A workaround is to specify -nobootcp to scalac and scala.

@som-snytt

This comment has been minimized.

Copy link

commented Apr 22, 2019

Actually, the part where it passes -classpath "" actually passes a classpath consisting of "", not an empty one.

https://github.com/scala/scala/blob/2.13.x/src/compiler/templates/tool-unix.tmpl#L202

So the reason the loader is touching the current dir is

$ scala -J-Dsun.misc.URLClassPath.debug=true hello.Main
Opening file:/Users/andrew/snips/%ed%a0%b5%ed%b4%98%ed%a0%b5%ed%b4%ab%ed%a0%b5%ed%b4%a6%ed%a0%b5%ed%b4%a0%ed%a0%b5%ed%b4%ac%ed%a0%b5%ed%b4%a1%ed%a0%b5%ed%b4%a2/%22%22

Similarly,

$ ls \"\"/nocp
C$.class	C.class
nocp $ scala
Welcome to Scala 2.12.8 (OpenJDK 64-Bit Server VM, Java 11.0.2).
Type in expressions for evaluation. Or try :help.

scala> nocp.C(42)
res0: nocp.C = C(42)

or

$ scala scala.tools.util.PathResolver
object Environment {
  scalaHome          = /Users/andrew/scala-2.12.8 (useJavaClassPath = true)
  javaBootClassPath  = <429 chars>
  javaExtDirs        = 
  javaUserClassPath  = ""
  scalaExtDirs       = 
}
@som-snytt

This comment has been minimized.

Copy link

commented Apr 22, 2019

It seems that if the user does not specify a class path, the tool could be started with java -jar, and with -classpath otherwise. A quick test shows that to work. -usejavacp can be shown the door at last. -Xlint ought to warn if a local dir named util (for example) is probed by the class path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.