Skip to content

-target: jvm-1.5 seems to generate calls to isEmpty on java.lang.String, which doesn't exist in JDK 1.5 #4702

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

Closed
scabug opened this issue Jun 16, 2011 · 3 comments

Comments

@scabug
Copy link

scabug commented Jun 16, 2011

Someone complained that ScalaTest 1.6.1 was not working on JDK 1.5. Their exception was:

Exception in thread "main" java.lang.NoSuchMethodError:
java.lang.String.isEmpty()Z
at org.scalatest.NodeFamily$.getTestName(NodeFamily.scala:99)

I double checked and the ant file that generated it does say target="jvm-1.5" inside every scalac element. I also checked and isEmpty was added to java.lang.String in JDK 1.6.

I tried this with just scalac 2.9.0 (Sorry I don't have 2.9.0-1 to try it on), and I got the same problem. I used the source file Simple.scala:

class Simple {
println("hi".isEmpty())
}

I compiled it with:

scalac -target:jvm-1.5 Simple.scala

When I do a javap -v Simple, I see the call to java.lang.String.isEmpty:

public Simple();
Code:
Stack=2, Locals=1, Args_size=1
0: aload_0
1: invokespecial #10; //Method java/lang/Object."":()V
4: getstatic #16; //Field scala/Predef$.MODULE$:Lscala/Predef$;
7: ldc #18; //String hi
9: invokevirtual #24; //Method java/lang/String.isEmpty:()Z
12: invokestatic #30; //Method scala/runtime/BoxesRunTime.boxToBoolean:(Z)Ljava/lang/Boolean;
15: invokevirtual #34; //Method scala/Predef$.println:(Ljava/lang/Object;)V
18: return
LineNumberTable:
line 2: 0
line 3: 4

@scabug
Copy link
Author

scabug commented Jun 16, 2011

Imported From: https://issues.scala-lang.org/browse/SUGGEST-5?orig=1
Reporter: @bvenners
Attachments:

  • Simple.class (created on Jun 16, 2011 12:59:18 AM UTC, 730 bytes)
  • Simple.scala (created on Jun 16, 2011 12:59:18 AM UTC, 44 bytes)

@scabug
Copy link
Author

scabug commented Jun 16, 2011

@paulp said:
target=1.5 refers to what version of bytecode to generate. It doesn't deal with this.

http://scala-programming-language.1934581.n4.nabble.com/Targetting-different-JVMs-was-scala-internals-First-candidate-for-2-8-0-beta-tt2006918.html

@scabug
Copy link
Author

scabug commented Jun 20, 2011

@SethTisue said:
if you want to compile on Java 6 but target Java 5, you also need to use -javabootclasspath to point to the Java 5 standard library.
(if you're on Mac OS X you don't have it and you have to grab it first from somewhere else.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant