Skip to content

Scala runner puts cwd ahead of its temporary -d on the class path #15015

Closed
@som-snytt

Description

@som-snytt

Compiler version

3.2.0-RC1

Minimized code

12 |object Test:
   |       ^
   |object Test differs only in case from class test. Such classes will overwrite one another on case-insensitive filesystems.
1 warning found
Exception in thread "main" java.lang.NoSuchMethodError: 'scala.languageFeature$postfixOps Test$.c()'
        at i15013$package$.test(i15013.scala:21)
        at test.main(i15013.scala:20)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at dotty.tools.scripting.ScriptingDriver.compileAndRun(ScriptingDriver.scala:36)
        at dotty.tools.scripting.Main$.main(Main.scala:45)
        at dotty.tools.MainGenericRunner$.run$1(MainGenericRunner.scala:248)
        at dotty.tools.MainGenericRunner$.main(MainGenericRunner.scala:267)
        at dotty.tools.MainGenericRunner.main(MainGenericRunner.scala)

Output

 rm *.class *.tasty
 ~/projects/dotty/bin/scala  i15013.scala
-- Warning: .../snips/i15013.scala:12:7 -----------------------------------------------------------------------
12 |object Test:
   |       ^
   |object Test differs only in case from class test. Such classes will overwrite one another on case-insensitive filesystems.
1 warning found
scala.languageFeature$postfixOps$@5b7ee56c

The warning was because

object Test
@main def test() = println()

But the error was that I had a local Test.class from previous experiments.

Expectation

As with REPL, I expect the compilation products of scala runner to "take precedence" over random files in my file system.

Either they should "come first" on the class path, or the class loaders should be constructed to prioritize an in-memory file system over the ordinary class path that uses the default file system.

I included the warning in this ticket just to show that the coincidence was unnecessarily confusing or distracting.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions