@@ -1362,17 +1362,29 @@ def _create_jvm(
13621362 sj .config .add_option ("-Djava.awt.headless=true" )
13631363 try :
13641364 if hasattr (sj , "jvm_version" ) and sj .jvm_version ()[0 ] >= 9 :
1365- # Disable illegal reflection access warnings.
1366- def add_open (mod_pack ):
1367- sj .config .add_option (f"--add-opens={ mod_pack } =ALL-UNNAMED" )
1368-
1369- add_open ("java.base/java.lang" )
1370- add_open ("java.base/java.util" )
1365+ # Allow illegal reflection access. Necessary for Java 17+.
1366+ mod_packs = [
1367+ "java.base/java.lang" ,
1368+ "java.base/java.lang.invoke" ,
1369+ "java.base/java.net" ,
1370+ "java.base/java.nio" ,
1371+ "java.base/java.time" ,
1372+ "java.base/java.util" ,
1373+ "java.base/java.util.concurrent.atomic" ,
1374+ "java.base/sun.nio.ch" ,
1375+ "java.base/sun.util.calendar" ,
1376+ "java.desktop/com.sun.java.swing" ,
1377+ "java.desktop/java.awt" ,
1378+ "java.desktop/javax.swing" ,
1379+ "java.desktop/sun.awt" ,
1380+ "java.desktop/sun.swing" ,
1381+ ]
13711382 if sys .platform == "linux" :
1372- add_open ("java.desktop/sun.awt.X11" )
1383+ mod_packs . append ("java.desktop/sun.awt.X11" )
13731384 elif sys .platform == "darwin" :
1374- add_open ("java.desktop/com.apple.eawt" )
1375-
1385+ mod_packs .append ("java.desktop/com.apple.eawt" )
1386+ for mod_pack in mod_packs :
1387+ sj .config .add_option (f"--add-opens={ mod_pack } =ALL-UNNAMED" )
13761388 except RuntimeError as e :
13771389 _logger .warning ("Failed to guess the Java version." )
13781390 _logger .debug (e , exc_info = True )
0 commit comments