JDK-8190783 : Exception when executing switch statement in static interface method
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9.0.1
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2017-10-28
  • Updated: 2017-12-02
  • Resolved: 2017-11-06
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
titan:bin tvo$ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
titan:bin tvo$ uname -a
Darwin titan.fritz.box 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64

EXTRA RELEVANT SYSTEM CONFIGURATION :
irrelevant

A DESCRIPTION OF THE PROBLEM :
running my program produces:

Exception in thread "main" java.lang.IllegalAccessError: Update to static final field de.thomasvogler.xxx.I.$SWITCH_TABLE$de$thomasvogler$xxx$V$T attempted from a different method ($SWITCH_TABLE$de$thomasvogler$xxx$V$T) than the initializer method <clinit> 
	at de.thomasvogler.xxx.I.$SWITCH_TABLE$de$thomasvogler$xxx$V$T(I.java:7)
	at de.thomasvogler.xxx.I.getH(I.java:29)
	at de.thomasvogler.xxx.I.create(I.java:15)
	at de.thomasvogler.xxx.Main.run(Main.java:11)
	at de.thomasvogler.xxx.Main.main(Main.java:6)


REGRESSION.  Last worked in version 8u162

ADDITIONAL REGRESSION INFORMATION: 
titan:bin tvo$ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run main in attached document

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
that the code does not throw an exception
ACTUAL -
exception as noted

ERROR MESSAGES/STACK TRACES THAT OCCUR :
see above

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
downloadable from http://www.thomas-vogler.de/javabug.tgz
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
none available


Comments
From submitter: I tried, just like you did, using javac to compile my source and the result is ok. I found this behaviour when running the code as eclipse java project. The class files included originated from an eclipse compile. When running those from the bin folder $ cd bin $ java de.thomasvogler.xxx.Main the crash happens. Probably eclipse compiles the source different? If i find the time, i will try a clean eclipse install and report an eclipse bug report.
07-11-2017

This is expected behavior. Closing as NAI.
06-11-2017

[~psonal] Can you find out from the submitter how the code is compiled? It doesn't appear to have been compiled with javac.
06-11-2017

To submitter: I executed the test case downloaded from http://www.thomas-vogler.de/javabug.tgz , however I am not able to reproduce the issue as described in the bug report. D:\javabug\XXX\src>javac de\thomasvogler\xxx\I.java de\thomasvogler\xxx\Main.java de\thomasvogler\xxx\V.java de\thomasvogler\xxx\VA.java de\thomasvogler\xxx\XI.java de\thomasvogler\xxx\YI.java D:\javabug\XXX\src>java -showversion de.thomasvogler.xxx.Main java version "9.0.1" Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode) 1 11 The output in JDK 8u151 and JDK 9.0.1 is the same. I am not getting any exception. Please let me know if you have any inputs that may help to reproduce the issue.
06-11-2017