1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | package Torello.Java.Additional.DataFiles; import static Torello.Java.C.BYELLOW; import static Torello.Java.C.RESET; import Torello.Java.ReadOnly.ReadOnlyArrayList; import Torello.Java.ReadOnly.ReadOnlyList; import Torello.Java.FileRW; import Torello.Java.Additional.Ret2; public class ConstantPoolData implements Torello.Java.Build.DataFileBuilderClass { public ConstantPoolData() { } private static final String DATA_FILE_NAME = "data3.r2dat"; public void build(String rootDir) throws java.io.IOException { final Ret2< ReadOnlyList<String>, ReadOnlyList<Byte> > r2part1 = new Ret2<>(tagNames, tagWidthBytes); System.out.println("Writing File: " + BYELLOW + rootDir + DATA_FILE_NAME + RESET); FileRW.writeObjectToFileNOCNFE(r2part1, rootDir + DATA_FILE_NAME, true); } // NOTE: THIS IS REUSED / BORROWED IN CLASS "ConstPooToStringData" // MUST BE PACKAGE-PRIVATE, CANNOT BE PRIVATE static final ReadOnlyList<String> tagNames = new ReadOnlyArrayList<>( // Note: The (String) cast is to "help" the Java-Compiler deal with its inability // to over-come some self-conscious behavior it has at dealing with Generic // Type Parameters. It is only needed in the very first 'null'. // // Precisely because it is 'null', the Java-Compiler is trying to associate the // Var-Args Parameter with a different constructor than the one I am trying to use. // Saying (String) forces it to accept which of the Constructor's I am trying to use! (String) null, // tag=0, UNUSED "UTF-8", // tag=1, null, // tag=2, UNUSED "Integer", // tag=3 "Float", // tag=4 "Long", // tag=5 "Double", // tag=6 "Class", // tag=7 "String", // tag=8 "FieldRef", // tag=9 "MethodRef", // tag=10 "InterfaceMethodRef", // tag=11 "NameAndType", // tag=12 null, // tag=13, UNUSED null, // tag=14, UNUSED "MethodHandle", // tag=15 "MethodType", // tag=16 "Dynamic", // tag=17 "InvokeDynamic", // tag=18 "Module", // tag=19 "Package" // tag=20 ); private static final ReadOnlyList<Byte> tagWidthBytes = new ReadOnlyArrayList<>( // This is a little "Helper Parameter" to the class "ReadOnlyArrayList" // It is doing nothing more than helping the Java-Compiler with its Generic // Type-Parameter foibles, vagaries and vicissitudes. Generic Erasure even seemed // to make Chat-GPT angry today. Byte.class, // These are Parameter-Values to a Var-Args Parameter (Byte) null, // tag=0, NOT A TAG null, // tag=1, CONSTANT_Utf8 - 'null' because the Size of a UTF-8 are Variable null, // tag=2 UNUSED (byte) 4, // tag=3, CONSTANT_Integer (byte) 4, // tag=4, CONSTANT_Float (byte) 8, // tag=5, CONSTANT_Long (byte) 8, // tag=6, CONSTANT_Double (byte) 2, // tag=7, CONSTANT_Class, The reference stores an index (byte) 2, // tag=8, CONSTANT_String, The reference stores an index (byte) 4, // tag=9, CONSTANT_Fieldref Each reference stores 2 indices (byte) 4, // tag=10, CONSTANT_Methodref Each reference stores 2 indices (byte) 4, // tag=11, CONSTANT_InterfaceMethodref Each reference stores 2 indices (byte) 4, // tag=12, CONSTANT_NameAndType Each reference stores 2 indices null, // tag=13, UNUSED null, // tag=14, UNUSED (byte) 3, // tag=15, CONSTANT_MethodHandle // 1 byte for reference kind + 2 bytes for index (byte) 2, // tag=16, CONSTANT_MethodType // 2 bytes for the index to a CONSTANT_Utf8 string (byte) 4, // tag=17 CONSTANT_Dynamic // 2 bytes for the bootstrap method index + // 2 bytes for the name and type index (byte) 4, // tag=18, CONSTANT_InvokeDynamic // 2 bytes for the bootstrap method index + // 2 bytes for the name and type index (byte) 2, // tag=19 CONSTANT_Module, The reference stores an index (byte) 2 // tag=20 CONSTANT_Package, The reference stores an index ); } |