Check-in [3a1b4cb8b5]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Base for loading of pool entries.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3a1b4cb8b52f879a57106e6d3220bc184281fd91
User & Date: stephanie.gawroriski 2019-04-17 12:24:30
Context
2019-04-17
13:50
Read of constant pool entries. check-in: 25dba2477e user: stephanie.gawroriski tags: trunk
12:24
Base for loading of pool entries. check-in: 3a1b4cb8b5 user: stephanie.gawroriski tags: trunk
07:02
Backup developer notes. check-in: 7d10eb6c2a user: squirreljme tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedClassFile.java.

87
88
89
90
91
92
93
94
95
96
97
98
99
		
		// Read class header
		MinimizedClassHeader header = MinimizedClassHeader.decode(
			new ByteArrayInputStream(__is));
		
		// Read constant pool
		MinimizedPool pool = MinimizedPool.decode(header.poolcount,
			new ByteArrayInputStream(__is, header.pooloff, header.poolsize));
		
		throw new todo.TODO();
	}
}








|





87
88
89
90
91
92
93
94
95
96
97
98
99
		
		// Read class header
		MinimizedClassHeader header = MinimizedClassHeader.decode(
			new ByteArrayInputStream(__is));
		
		// Read constant pool
		MinimizedPool pool = MinimizedPool.decode(header.poolcount,
			__is, header.pooloff, header.poolsize);
		
		throw new todo.TODO();
	}
}

Changes to runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedPool.java.

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
..
59
60
61
62
63
64
65
66














































67
68
69
70
{
	
	/**
	 * Decodes the minimized constant pool.
	 *
	 * @param __n Number of entries in the pool.
	 * @param __is The bytes to decode from.


	 * @return The resulting minimized pool.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static final MinimizedPool decode(int __n, InputStream __is)

		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		DataInputStream dis = new DataInputStream(__is);

		
		// Debug
		todo.DEBUG.note("Decode %d (%d bytes)", __n, __is.available());
		
		// Read type table
		byte[] types = new byte[__n];
		dis.readFully(types);
		
		// Skip padding?
		if ((__n & 1) != 0)
................................................................................
		for (int i = 0; i < __n; i++)
			offsets[i] = dis.readUnsignedShort();
		
		// Read of all the various entries
		for (int i = 0; i < __n; i++)
			todo.DEBUG.note("%3d: %02x (@%d)", i,
				(types[i] & 0xFF), offsets[i]);
		














































		throw new todo.TODO();
	}
}








>
>







|
>





|
>


|







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




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
..
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
112
113
114
115
116
117
118
119
120
{
	
	/**
	 * Decodes the minimized constant pool.
	 *
	 * @param __n Number of entries in the pool.
	 * @param __is The bytes to decode from.
	 * @param __o The offset into the array.
	 * @param __l The length of the array.
	 * @return The resulting minimized pool.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.
	 * @throws IOException On read errors.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static final MinimizedPool decode(int __n, byte[] __is, int __o,
		int __l)
		throws InvalidClassFormatException, IOException, NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		
		DataInputStream dis = new DataInputStream(
			new ByteArrayInputStream(__is, __o, __l));
		
		// Debug
		todo.DEBUG.note("Decode %d (%d bytes)", __n, __l);
		
		// Read type table
		byte[] types = new byte[__n];
		dis.readFully(types);
		
		// Skip padding?
		if ((__n & 1) != 0)
................................................................................
		for (int i = 0; i < __n; i++)
			offsets[i] = dis.readUnsignedShort();
		
		// Read of all the various entries
		for (int i = 0; i < __n; i++)
			todo.DEBUG.note("%3d: %02x (@%d)", i,
				(types[i] & 0xFF), offsets[i]);
		
		// Output pool entry types, values, and parts
		int[][] parts = new int[__n][];
		Object[] values = new Object[__n];
		
		// Zero int for empty parts
		int[] nopart = new int[0];
		
		// Re-build individual pool entries
		Object[] entries = new Object[__n];
		for (int i = 0; i < __n; i++)
		{
			// Get type and pointer
			int rawtype = types[i],
				ptr = offsets[i];
			
			// Is this wide?
			boolean iswide;
			if ((iswide = ((rawtype & 0x80) != 0)))
			{
				rawtype &= 0x7F;
				
				// Re-adjust type array since we use this for the type list
				types[i] = (byte)rawtype;
			}
			
			// Read info
			int[] part = null;
			Object v = null;
			
			// Depends on the type
			MinimizedPoolEntryType type = MinimizedPoolEntryType.of(rawtype);
			switch (type)
			{
					// Null is nothing, so do not bother
				case NULL:
					break;
				
				default:
					throw new todo.OOPS(type.name());
			}
			
			// Set data
			parts[i] = (part == null ? nopart : part);
			values[i] = v;
		}
		
		throw new todo.TODO();
	}
}

Changes to runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedPoolBuilder.java.

384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
						// Everything else just consists of parts which are
						// either values to other indexes or an ordinal
					case ACCESSED_FIELD:
					case CLASS_NAME:
					case CLASS_NAMES:
					case INVOKED_METHOD:
					case FIELD_DESCRIPTOR:
					case FIELD_NAME:
					case FIELD_REFERENCE:
					case METHOD_DESCRIPTOR:
					case METHOD_HANDLE:
					case METHOD_NAME:
						{
							// Write number of parts
							int npart = part.length;
							if (iswide)
								ddos.writeShort(
									Minimizer.__checkUShort(npart));
							else







<
<

<
<







384
385
386
387
388
389
390


391


392
393
394
395
396
397
398
						// Everything else just consists of parts which are
						// either values to other indexes or an ordinal
					case ACCESSED_FIELD:
					case CLASS_NAME:
					case CLASS_NAMES:
					case INVOKED_METHOD:
					case FIELD_DESCRIPTOR:


					case METHOD_DESCRIPTOR:


						{
							// Write number of parts
							int npart = part.length;
							if (iswide)
								ddos.writeShort(
									Minimizer.__checkUShort(npart));
							else

Changes to runt/libs/tool-classfile/dev/shadowtail/classfile/mini/MinimizedPoolEntryType.java.

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
...
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
	/** Nothing. */
	NULL,
	
	/** String. */
	STRING,
	
	/** Accessed Field. */
	ACCESSED_FIELD,
	
	/** Name of class. */
	CLASS_NAME,
	
	/** Class names (used for interfaces). */
	CLASS_NAMES,
	
	/** Double. */
	DOUBLE,
	
	/** Invoked Method. */
	INVOKED_METHOD,
	
	/** Field Descriptor. */
	FIELD_DESCRIPTOR,
	
	/** Field Name. */
	FIELD_NAME,
	
	/** Field Reference. */
	FIELD_REFERENCE,



	
	/** Float. */
	FLOAT,
	
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** Method Descriptor. */
	METHOD_DESCRIPTOR,
	

	/** Method Handle. */
	METHOD_HANDLE,

	
	/** Method name, */
	METHOD_NAME,





	
	/** End. */















	;



	
	/**
	 * Returns the entry type that is used for the specified class.
	 *
	 * @param __cl The class to check.
	 * @return The entry type for the class.
	 * @throws IllegalArgumentException On null arguments.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public static final MinimizedPoolEntryType ofClass(Class<?> __cl)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null)
................................................................................
				return CLASS_NAME;
			case "net.multiphasicapps.classfile.ClassNames":
				return CLASS_NAMES;
			case "List net.multiphasicapps.classfile.ClassName":
				return CLASS_NAMES;
			case "net.multiphasicapps.classfile.FieldDescriptor":
				return FIELD_DESCRIPTOR;
			case "net.multiphasicapps.classfile.FieldName":
				return FIELD_NAME;
			case "net.multiphasicapps.classfile.FieldReference":
				return FIELD_REFERENCE;
			case "net.multiphasicapps.classfile.MethodDescriptor":
				return METHOD_DESCRIPTOR;
			case "net.multiphasicapps.classfile.MethodHandle":
				return METHOD_HANDLE;
			case "net.multiphasicapps.classfile.MethodName":
				return METHOD_NAME;
		}
		
		// {@squirreljme.error JC2o Class does not map to a pool entry
		// type. (The class)}
		throw new IllegalArgumentException("JC2o " + __cl);
	}
}








<
<
<






|
|
<
<
<




|
|

|
|
>
>
>










|
<
|
>
|
<
>
|
|
|
>
>
>
>
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>






|







 







<
<
<
<



<
<
<








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
...
122
123
124
125
126
127
128




129
130
131



132
133
134
135
136
137
138
139
{
	/** Nothing. */
	NULL,
	
	/** String. */
	STRING,
	



	/** Name of class. */
	CLASS_NAME,
	
	/** Class names (used for interfaces). */
	CLASS_NAMES,
	
	/** Accessed Field. */
	ACCESSED_FIELD,



	
	/** Field Descriptor. */
	FIELD_DESCRIPTOR,
	
	/** Invoked Method. */
	INVOKED_METHOD,
	
	/** Method Descriptor. */
	METHOD_DESCRIPTOR,
	
	/** Double. */
	DOUBLE,
	
	/** Float. */
	FLOAT,
	
	/** Integer. */
	INTEGER,
	
	/** Long. */
	LONG,
	
	/** End. */

	;
	
	/**

	 * Returns the type for the specified index.
	 *
	 * @param __i The index to get.
	 * @return The type for this index.
	 * @throws IllegalArgumentException If the type is not valid.
	 * @since 2019/04/17
	 */
	public static final MinimizedPoolEntryType of(int __i)
		throws IllegalArgumentException
	{

		switch (__i)
		{
			case 0:		return NULL;
			case 1:		return STRING;
			case 2:		return CLASS_NAME;
			case 3:		return CLASS_NAMES;
			case 4:		return ACCESSED_FIELD;
			case 5:		return FIELD_DESCRIPTOR;
			case 6:		return INVOKED_METHOD;
			case 7:		return METHOD_DESCRIPTOR;
			case 8:		return DOUBLE;
			case 9:		return FLOAT;
			case 10:	return INTEGER;
			case 11:	return LONG;
		}
		
		// {@squirreljme.error JC3s Unknown pool type. (The type)}
		throw new IllegalArgumentException("JC3s " + __i);
	}
	
	/**
	 * Returns the entry type that is used for the specified class.
	 *
	 * @param __cl The class to check.
	 * @return The entry type for the class.
	 * @throws IllegalArgumentException If the class is not valid.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/14
	 */
	public static final MinimizedPoolEntryType ofClass(Class<?> __cl)
		throws IllegalArgumentException, NullPointerException
	{
		if (__cl == null)
................................................................................
				return CLASS_NAME;
			case "net.multiphasicapps.classfile.ClassNames":
				return CLASS_NAMES;
			case "List net.multiphasicapps.classfile.ClassName":
				return CLASS_NAMES;
			case "net.multiphasicapps.classfile.FieldDescriptor":
				return FIELD_DESCRIPTOR;




			case "net.multiphasicapps.classfile.MethodDescriptor":
				return METHOD_DESCRIPTOR;
			case "net.multiphasicapps.classfile.MethodHandle":



		}
		
		// {@squirreljme.error JC2o Class does not map to a pool entry
		// type. (The class)}
		throw new IllegalArgumentException("JC2o " + __cl);
	}
}