-
Notifications
You must be signed in to change notification settings - Fork 21
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
{ final, regular } vals could be better optimized #4605
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4605?orig=1 |
@paulp said (edited on Dec 16, 2011 7:52:04 AM UTC):
|
@SethTisue said: |
@VladUreche said: |
@paulp said: |
@ijuma said: "it doesn't override the method, it instead overwrites the java-private-final value of the field in the constructor" This is not true. "The JVM as far as I know doesn't have the level of effect tracking Not true again. David Homes, a HotSpot committer, says: "So the compiler can optimize away re-loading of final fields, even if Check the full explanation here: http://cs.oswego.edu/pipermail/concurrency-interest/2011-January/007723.html |
Chris Sachs (c9r) said: An alternative solution might be to permit Please unburden our precious little stable identifiers from the crushing weight of gc-intensive java fields. |
@paulp said: |
@adriaanm said: |
@paulp said: |
Chris Sachs (c9r) said: // Test.java
public abstract class Test {
public int iHaveAField;
}
Compiled from "Test.java"
public abstract class Test {
public int iHaveAField;
public Test();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
} // Test.scala
abstract class Test {
val dudeWheresMyField: Int
}
|
2.12 does not generate the field |
When I compile finalval.scala with content:
an unused private attribute "private final int c;" in A$$.class is created (JD-GUI output):
A.class
A$$.class
Scala version was 2.9.0.final
java compiler version was 1.6.0_18
The text was updated successfully, but these errors were encountered: