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

@volatile val generates invalid class file #2095

Closed
scabug opened this issue Jun 25, 2009 · 3 comments
Closed

@volatile val generates invalid class file #2095

scabug opened this issue Jun 25, 2009 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Jun 25, 2009

A @volatile val is accepted by the compiler, but triggers a ClassFormatError when an attempt is made to load it.

In the REPL:

Welcome to Scala version 2.7.5.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_14).
Type in expressions to have them evaluated.
Type :help for more information.

scala> class C { @volatile val x = 10 }
defined class C

scala> new C
java.lang.ClassFormatError: Illegal field modifiers in class C: 0x52
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
	at scala.tools.nsc.interpreter.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:30)
	at java.lang.ClassLoader.loadClass(ClassLoa...
@scabug
Copy link
Author

scabug commented Jun 25, 2009

Imported From: https://issues.scala-lang.org/browse/SI-2095?orig=1
Reporter: Nathan Bronson (nbronson)

@scabug
Copy link
Author

scabug commented Sep 4, 2009

@dragos said:
Fixed in r18645 by issuing a compile-time error.

@scabug
Copy link
Author

scabug commented Sep 5, 2009

@dcaoyuan said:
Please also modify the test/file/pos/attributes.scala, which can not pass test now, print:

  [partest] testing: [...]/files/pos/attributes.scala                             [FAILED]
  [partest] attributes.scala:40: error: values cannot be volatile
  [partest]   @serializable @volatile  val x2 = new C2;
  [partest]                                ^
  [partest] attributes.scala:41: error: values cannot be volatile
  [partest]   @serializable @volatile  val x3 = new C3;
  [partest]                                ^
  [partest] attributes.scala:42: error: values cannot be volatile
  [partest]   @serializable @volatile @serializable  val x4 = new C4;
  [partest]                                              ^
  [partest] three errors found

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

No branches or pull requests

2 participants