private static NativeType[] buildNativeTypeAliases() { Platform platform = Platform.getNativePlatform(); Package pkg = NativeRuntime.class.getPackage(); String cpu = platform.getCPU().toString(); String os = platform.getOS().toString(); EnumSet<TypeAlias> typeAliases = EnumSet.allOf(TypeAlias.class); NativeType[] aliases = {}; Class cls; try { cls = Class.forName(pkg.getName() + ".platform." + cpu + "." + os + ".TypeAliases"); Field aliasesField = cls.getField("ALIASES"); Map aliasMap = Map.class.cast(aliasesField.get(cls)); aliases = new NativeType[typeAliases.size()]; for (TypeAlias t : typeAliases) { aliases[t.ordinal()] = (NativeType) aliasMap.get(t); if (aliases[t.ordinal()] == null) { aliases[t.ordinal()] = NativeType.VOID; } } } catch (ClassNotFoundException cne) { Logger.getLogger(NativeRuntime.class.getName()).log(Level.SEVERE, "failed to load type aliases: " + cne); } catch (NoSuchFieldException nsfe) { Logger.getLogger(NativeRuntime.class.getName()).log(Level.SEVERE, "failed to load type aliases: " + nsfe); } catch (IllegalAccessException iae) { Logger.getLogger(NativeRuntime.class.getName()).log(Level.SEVERE, "failed to load type aliases: " + iae); } return aliases; }
private static NativeType[] buildNativeTypeAliases() { Platform platform = Platform.getNativePlatform(); Package pkg = NativeRuntime.class.getPackage(); String cpu = platform.getCPU().toString(); String os = platform.getOS().toString(); EnumSet<TypeAlias> typeAliases = EnumSet.allOf(TypeAlias.class); NativeType[] aliases = {}; Class cls; try { cls = Class.forName(pkg.getName() + ".platform." + cpu + "." + os + ".TypeAliases"); Field aliasesField = cls.getField("ALIASES"); Map aliasMap = Map.class.cast(aliasesField.get(cls)); aliases = new NativeType[typeAliases.size()]; for (TypeAlias t : typeAliases) { aliases[t.ordinal()] = (NativeType) aliasMap.get(t); if (aliases[t.ordinal()] == null) { aliases[t.ordinal()] = NativeType.VOID; } } } catch (ClassNotFoundException cne) { Logger.getLogger(NativeRuntime.class.getName()).log(Level.SEVERE, "failed to load type aliases: " + cne); } catch (NoSuchFieldException nsfe) { Logger.getLogger(NativeRuntime.class.getName()).log(Level.SEVERE, "failed to load type aliases: " + nsfe); } catch (IllegalAccessException iae) { Logger.getLogger(NativeRuntime.class.getName()).log(Level.SEVERE, "failed to load type aliases: " + iae); } return aliases; }
private static NativeType[] buildNativeTypeAliases() { Platform platform = Platform.getNativePlatform(); Package pkg = NativeRuntime.class.getPackage(); String cpu = platform.getCPU().toString(); String os = platform.getOS().toString(); EnumSet<TypeAlias> typeAliases = EnumSet.allOf(TypeAlias.class); NativeType[] aliases = {}; Class cls; try { cls = Class.forName(pkg.getName() + ".platform." + cpu + "." + os + ".TypeAliases"); Field aliasesField = cls.getField("ALIASES"); Map aliasMap = Map.class.cast(aliasesField.get(cls)); aliases = new NativeType[typeAliases.size()]; for (TypeAlias t : typeAliases) { aliases[t.ordinal()] = (NativeType) aliasMap.get(t); if (aliases[t.ordinal()] == null) { aliases[t.ordinal()] = NativeType.VOID; } } } catch (ClassNotFoundException cne) { Logger.getLogger(NativeRuntime.class.getName()).log(Level.SEVERE, "failed to load type aliases: " + cne); } catch (NoSuchFieldException nsfe) { Logger.getLogger(NativeRuntime.class.getName()).log(Level.SEVERE, "failed to load type aliases: " + nsfe); } catch (IllegalAccessException iae) { Logger.getLogger(NativeRuntime.class.getName()).log(Level.SEVERE, "failed to load type aliases: " + iae); } return aliases; }