7070import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
7171import com .oracle .truffle .api .TruffleFile ;
7272import com .oracle .truffle .api .TruffleLanguage ;
73- import com .oracle .truffle .espresso .classfile .descriptors .Name ;
74- import com .oracle .truffle .espresso .classfile .descriptors .Symbol ;
7573import com .oracle .truffle .espresso .descriptors .EspressoSymbols ;
7674import com .oracle .truffle .espresso .descriptors .EspressoSymbols .Names ;
7775import com .oracle .truffle .espresso .descriptors .EspressoSymbols .Signatures ;
8179import com .oracle .truffle .espresso .impl .Method ;
8280import com .oracle .truffle .espresso .impl .ObjectKlass ;
8381import com .oracle .truffle .espresso .libs .LibsState ;
84- import com .oracle .truffle .espresso .meta .EspressoError ;
8582import com .oracle .truffle .espresso .meta .Meta ;
8683import com .oracle .truffle .espresso .runtime .EspressoContext ;
8784import com .oracle .truffle .espresso .runtime .OS ;
@@ -143,10 +140,10 @@ public final class TruffleIO implements ContextAccess {
143140 public final Method sun_nio_fs_DefaultFileSystemProvider_instance ;
144141
145142 public final ObjectKlass sun_nio_fs_FileAttributeParser ;
146- @ CompilationFinal public FileAttributeParser_Sync fileAttributeParserSync ;
143+ public final FileAttributeParser_Sync fileAttributeParserSync ;
147144
148145 public final ObjectKlass sun_nio_ch_FileChannelImpl ;
149- @ CompilationFinal public FileChannelImpl_Sync fileChannelImplSync ;
146+ public final FileChannelImpl_Sync fileChannelImplSync ;
150147
151148 public final ObjectKlass sun_nio_ch_IOStatus ;
152149 public final IOStatus_Sync ioStatusSync ;
@@ -158,7 +155,7 @@ public final class TruffleIO implements ContextAccess {
158155 public final InetAddressResolver_LookupPolicy_Sync inetAddressResolverLookupPolicySync ;
159156
160157 public final ObjectKlass sun_nio_ch_Net ;
161- @ CompilationFinal public Net_ShutFlags_Sync netShutFlagsSync ;
158+ public final Net_ShutFlags_Sync netShutFlagsSync ;
162159
163160 // Checkstyle: resume field name check
164161
@@ -1121,11 +1118,13 @@ public TruffleIO(EspressoContext context) {
11211118 sun_nio_fs_DefaultFileSystemProvider_instance = sun_nio_fs_DefaultFileSystemProvider .requireDeclaredMethod (Names .instance , Signatures .sun_nio_fs_TruffleFileSystemProvider );
11221119
11231120 sun_nio_fs_FileAttributeParser = meta .knownKlass (EspressoSymbols .Types .sun_nio_fs_FileAttributeParser );
1121+ this .fileAttributeParserSync = new FileAttributeParser_Sync (this );
11241122
11251123 sun_nio_ch_IOStatus = meta .knownKlass (EspressoSymbols .Types .sun_nio_ch_IOStatus );
11261124 ioStatusSync = new IOStatus_Sync (this );
11271125
11281126 sun_nio_ch_FileChannelImpl = meta .knownKlass (EspressoSymbols .Types .sun_nio_ch_FileChannelImpl );
1127+ this .fileChannelImplSync = new FileChannelImpl_Sync (this );
11291128
11301129 sun_nio_fs_TrufflePath = meta .knownKlass (Types .sun_nio_fs_TrufflePath );
11311130 sun_nio_fs_TrufflePath_HIDDEN_TRUFFLE_FILE = sun_nio_fs_TrufflePath .requireHiddenField (Names .HIDDEN_TRUFFLE_FILE );
@@ -1137,19 +1136,11 @@ public TruffleIO(EspressoContext context) {
11371136 inetAddressResolverLookupPolicySync = new InetAddressResolver_LookupPolicy_Sync (this );
11381137
11391138 sun_nio_ch_Net = meta .knownKlass (Types .sun_nio_ch_Net );
1139+ netShutFlagsSync = new Net_ShutFlags_Sync (this );
11401140
11411141 setEnv (context .getEnv ());
11421142 }
11431143
1144- /**
1145- * See {@link Meta#postSystemInit()}.
1146- */
1147- public void postSystemInit () {
1148- this .fileAttributeParserSync = new FileAttributeParser_Sync (this );
1149- this .fileChannelImplSync = new FileChannelImpl_Sync (this );
1150- netShutFlagsSync = new Net_ShutFlags_Sync (this );
1151- }
1152-
11531144 private void setEnv (TruffleLanguage .Env env ) {
11541145 synchronized (files ) {
11551146 files .get (FD_STDIN ).setNewChannel (new DetachOnCloseInputStream (env .in ()));
@@ -1391,13 +1382,6 @@ private SeekableByteChannel getSeekableChannel(int fd) {
13911382 throw Throw .throwNonSeekable (context );
13921383 }
13931384
1394- private static int lookupSyncedValue (ObjectKlass klass , Symbol <Name > constant ) {
1395- Field f = klass .lookupDeclaredField (constant , Types ._int );
1396- EspressoError .guarantee (f != null , "Failed to sync " + klass .getExternalName () + " constants" );
1397- assert f .isStatic ();
1398- return f .getInt (klass .tryInitializeAndGetStatics ());
1399- }
1400-
14011385 // Checkstyle: stop field name check
14021386 public static final class RAF_Sync {
14031387 public final int O_RDONLY ;
@@ -1407,11 +1391,11 @@ public static final class RAF_Sync {
14071391 public final int O_TEMPORARY ;
14081392
14091393 public RAF_Sync (TruffleIO io ) {
1410- this .O_RDONLY = lookupSyncedValue (io .java_io_RandomAccessFile , Names .O_RDONLY );
1411- this .O_RDWR = lookupSyncedValue (io .java_io_RandomAccessFile , Names .O_RDWR );
1412- this .O_SYNC = lookupSyncedValue (io .java_io_RandomAccessFile , Names .O_SYNC );
1413- this .O_DSYNC = lookupSyncedValue (io .java_io_RandomAccessFile , Names .O_DSYNC );
1414- this .O_TEMPORARY = lookupSyncedValue (io .java_io_RandomAccessFile , Names .O_TEMPORARY );
1394+ this .O_RDONLY = Meta . getIntConstant (io .java_io_RandomAccessFile , Names .O_RDONLY );
1395+ this .O_RDWR = Meta . getIntConstant (io .java_io_RandomAccessFile , Names .O_RDWR );
1396+ this .O_SYNC = Meta . getIntConstant (io .java_io_RandomAccessFile , Names .O_SYNC );
1397+ this .O_DSYNC = Meta . getIntConstant (io .java_io_RandomAccessFile , Names .O_DSYNC );
1398+ this .O_TEMPORARY = Meta . getIntConstant (io .java_io_RandomAccessFile , Names .O_TEMPORARY );
14151399 }
14161400 }
14171401
@@ -1426,13 +1410,13 @@ public static final class FileSystem_Sync {
14261410 public final int ACCESS_EXECUTE ;
14271411
14281412 public FileSystem_Sync (TruffleIO io ) {
1429- this .BA_EXISTS = lookupSyncedValue (io .java_io_FileSystem , Names .BA_EXISTS );
1430- this .BA_REGULAR = lookupSyncedValue (io .java_io_FileSystem , Names .BA_REGULAR );
1431- this .BA_DIRECTORY = lookupSyncedValue (io .java_io_FileSystem , Names .BA_DIRECTORY );
1432- this .BA_HIDDEN = lookupSyncedValue (io .java_io_FileSystem , Names .BA_HIDDEN );
1433- this .ACCESS_READ = lookupSyncedValue (io .java_io_FileSystem , Names .ACCESS_READ );
1434- this .ACCESS_WRITE = lookupSyncedValue (io .java_io_FileSystem , Names .ACCESS_WRITE );
1435- this .ACCESS_EXECUTE = lookupSyncedValue (io .java_io_FileSystem , Names .ACCESS_EXECUTE );
1413+ this .BA_EXISTS = Meta . getIntConstant (io .java_io_FileSystem , Names .BA_EXISTS );
1414+ this .BA_REGULAR = Meta . getIntConstant (io .java_io_FileSystem , Names .BA_REGULAR );
1415+ this .BA_DIRECTORY = Meta . getIntConstant (io .java_io_FileSystem , Names .BA_DIRECTORY );
1416+ this .BA_HIDDEN = Meta . getIntConstant (io .java_io_FileSystem , Names .BA_HIDDEN );
1417+ this .ACCESS_READ = Meta . getIntConstant (io .java_io_FileSystem , Names .ACCESS_READ );
1418+ this .ACCESS_WRITE = Meta . getIntConstant (io .java_io_FileSystem , Names .ACCESS_WRITE );
1419+ this .ACCESS_EXECUTE = Meta . getIntConstant (io .java_io_FileSystem , Names .ACCESS_EXECUTE );
14361420 }
14371421 }
14381422
@@ -1448,23 +1432,25 @@ public static final class FileAttributeParser_Sync {
14481432 public final int OTHERS_EXECUTE_VALUE ;
14491433
14501434 public FileAttributeParser_Sync (TruffleIO io ) {
1451- this .OWNER_READ_VALUE = lookupSyncedValue (io .sun_nio_fs_FileAttributeParser , Names .OWNER_READ_VALUE );
1452- this .OWNER_WRITE_VALUE = lookupSyncedValue (io .sun_nio_fs_FileAttributeParser , Names .OWNER_WRITE_VALUE );
1453- this .OWNER_EXECUTE_VALUE = lookupSyncedValue (io .sun_nio_fs_FileAttributeParser , Names .OWNER_EXECUTE_VALUE );
1454- this .GROUP_READ_VALUE = lookupSyncedValue (io .sun_nio_fs_FileAttributeParser , Names .GROUP_READ_VALUE );
1455- this .GROUP_WRITE_VALUE = lookupSyncedValue (io .sun_nio_fs_FileAttributeParser , Names .GROUP_WRITE_VALUE );
1456- this .GROUP_EXECUTE_VALUE = lookupSyncedValue (io .sun_nio_fs_FileAttributeParser , Names .GROUP_EXECUTE_VALUE );
1457- this .OTHERS_READ_VALUE = lookupSyncedValue (io .sun_nio_fs_FileAttributeParser , Names .OTHERS_READ_VALUE );
1458- this .OTHERS_WRITE_VALUE = lookupSyncedValue (io .sun_nio_fs_FileAttributeParser , Names .OTHERS_WRITE_VALUE );
1459- this .OTHERS_EXECUTE_VALUE = lookupSyncedValue (io .sun_nio_fs_FileAttributeParser , Names .OTHERS_EXECUTE_VALUE );
1435+ // if this would fail we would need to load the class at post system init.
1436+ this .OWNER_READ_VALUE = Meta .getIntConstant (io .sun_nio_fs_FileAttributeParser , Names .OWNER_READ_VALUE , false );
1437+ this .OWNER_WRITE_VALUE = Meta .getIntConstant (io .sun_nio_fs_FileAttributeParser , Names .OWNER_WRITE_VALUE , false );
1438+ this .OWNER_EXECUTE_VALUE = Meta .getIntConstant (io .sun_nio_fs_FileAttributeParser , Names .OWNER_EXECUTE_VALUE , false );
1439+ this .GROUP_READ_VALUE = Meta .getIntConstant (io .sun_nio_fs_FileAttributeParser , Names .GROUP_READ_VALUE , false );
1440+ this .GROUP_WRITE_VALUE = Meta .getIntConstant (io .sun_nio_fs_FileAttributeParser , Names .GROUP_WRITE_VALUE , false );
1441+ this .GROUP_EXECUTE_VALUE = Meta .getIntConstant (io .sun_nio_fs_FileAttributeParser , Names .GROUP_EXECUTE_VALUE , false );
1442+ this .OTHERS_READ_VALUE = Meta .getIntConstant (io .sun_nio_fs_FileAttributeParser , Names .OTHERS_READ_VALUE , false );
1443+ this .OTHERS_WRITE_VALUE = Meta .getIntConstant (io .sun_nio_fs_FileAttributeParser , Names .OTHERS_WRITE_VALUE , false );
1444+ this .OTHERS_EXECUTE_VALUE = Meta .getIntConstant (io .sun_nio_fs_FileAttributeParser , Names .OTHERS_EXECUTE_VALUE , false );
14601445 }
14611446 }
14621447
14631448 public static final class FileChannelImpl_Sync {
14641449 public final int MAP_RW ;
14651450
14661451 public FileChannelImpl_Sync (TruffleIO io ) {
1467- this .MAP_RW = lookupSyncedValue (io .sun_nio_ch_FileChannelImpl , Names .MAP_RW );
1452+ // if this would fail we would need to load the class at post system init.
1453+ this .MAP_RW = Meta .getIntConstant (io .sun_nio_ch_FileChannelImpl , Names .MAP_RW , false );
14681454 }
14691455 }
14701456
@@ -1477,12 +1463,12 @@ public static final class IOStatus_Sync {
14771463 public final int UNSUPPORTED_CASE ;
14781464
14791465 public IOStatus_Sync (TruffleIO io ) {
1480- this .EOF = lookupSyncedValue (io .sun_nio_ch_IOStatus , Names .EOF );
1481- this .UNAVAILABLE = lookupSyncedValue (io .sun_nio_ch_IOStatus , Names .UNAVAILABLE );
1482- this .INTERRUPTED = lookupSyncedValue (io .sun_nio_ch_IOStatus , Names .INTERRUPTED );
1483- this .UNSUPPORTED = lookupSyncedValue (io .sun_nio_ch_IOStatus , Names .UNSUPPORTED );
1484- this .THROWN = lookupSyncedValue (io .sun_nio_ch_IOStatus , Names .THROWN );
1485- this .UNSUPPORTED_CASE = lookupSyncedValue (io .sun_nio_ch_IOStatus , Names .UNSUPPORTED_CASE );
1466+ this .EOF = Meta . getIntConstant (io .sun_nio_ch_IOStatus , Names .EOF );
1467+ this .UNAVAILABLE = Meta . getIntConstant (io .sun_nio_ch_IOStatus , Names .UNAVAILABLE );
1468+ this .INTERRUPTED = Meta . getIntConstant (io .sun_nio_ch_IOStatus , Names .INTERRUPTED );
1469+ this .UNSUPPORTED = Meta . getIntConstant (io .sun_nio_ch_IOStatus , Names .UNSUPPORTED );
1470+ this .THROWN = Meta . getIntConstant (io .sun_nio_ch_IOStatus , Names .THROWN );
1471+ this .UNSUPPORTED_CASE = Meta . getIntConstant (io .sun_nio_ch_IOStatus , Names .UNSUPPORTED_CASE );
14861472 }
14871473 }
14881474
@@ -1493,10 +1479,10 @@ public static final class InetAddressResolver_LookupPolicy_Sync {
14931479 public final int IPV6_FIRST ;
14941480
14951481 public InetAddressResolver_LookupPolicy_Sync (TruffleIO io ) {
1496- this .IPV4 = lookupSyncedValue (io .java_net_spi_InetAddressResolver$LookupPolicy , Names .IPV4 );
1497- this .IPV6 = lookupSyncedValue (io .java_net_spi_InetAddressResolver$LookupPolicy , Names .IPV6 );
1498- this .IPV4_FIRST = lookupSyncedValue (io .java_net_spi_InetAddressResolver$LookupPolicy , Names .IPV4_FIRST );
1499- this .IPV6_FIRST = lookupSyncedValue (io .java_net_spi_InetAddressResolver$LookupPolicy , Names .IPV6_FIRST );
1482+ this .IPV4 = Meta . getIntConstant (io .java_net_spi_InetAddressResolver$LookupPolicy , Names .IPV4 );
1483+ this .IPV6 = Meta . getIntConstant (io .java_net_spi_InetAddressResolver$LookupPolicy , Names .IPV6 );
1484+ this .IPV4_FIRST = Meta . getIntConstant (io .java_net_spi_InetAddressResolver$LookupPolicy , Names .IPV4_FIRST );
1485+ this .IPV6_FIRST = Meta . getIntConstant (io .java_net_spi_InetAddressResolver$LookupPolicy , Names .IPV6_FIRST );
15001486 }
15011487 }
15021488
@@ -1506,9 +1492,10 @@ public static final class Net_ShutFlags_Sync {
15061492 public final int SHUT_RDWR ;
15071493
15081494 public Net_ShutFlags_Sync (TruffleIO io ) {
1509- this .SHUT_RD = lookupSyncedValue (io .sun_nio_ch_Net , Names .SHUT_RD );
1510- this .SHUT_WR = lookupSyncedValue (io .sun_nio_ch_Net , Names .SHUT_WR );
1511- this .SHUT_RDWR = lookupSyncedValue (io .sun_nio_ch_Net , Names .SHUT_RDWR );
1495+ // if this would fail we would need to load the class at post system init.
1496+ this .SHUT_RD = Meta .getIntConstant (io .sun_nio_ch_Net , Names .SHUT_RD , false );
1497+ this .SHUT_WR = Meta .getIntConstant (io .sun_nio_ch_Net , Names .SHUT_WR , false );
1498+ this .SHUT_RDWR = Meta .getIntConstant (io .sun_nio_ch_Net , Names .SHUT_RDWR , false );
15121499 }
15131500 }
15141501 // Checkstyle: resume field name check
0 commit comments