Check-in [7d2c0c8082]

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

Overview
Comment:Base calls for loading class fields and methods.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7d2c0c80821b39a4afb8e4cbc58c3fa1a899a36f
User & Date: stephanie.gawroriski 2019-04-17 14:15:06
Context
2019-04-17
15:33
Reading of fields. check-in: 8e5a504986 user: stephanie.gawroriski tags: trunk
14:15
Base calls for loading class fields and methods. check-in: 7d2c0c8082 user: stephanie.gawroriski tags: trunk
14:00
Pool data is read. check-in: 838a415bd9 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

89
90
91
92
93
94
95












96
97
98
99
		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();
	}
}








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




89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
		MinimizedClassHeader header = MinimizedClassHeader.decode(
			new ByteArrayInputStream(__is));
		
		// Read constant pool
		MinimizedPool pool = MinimizedPool.decode(header.poolcount,
			__is, header.pooloff, header.poolsize);
		
		// Read static and instance fields
		MinimizedField[] sfields = MinimizedField.decodeFields(
				header.sfcount, pool, __is, header.sfoff, header.sfsize),
			ifields = MinimizedField.decodeFields(
				header.ifcount, pool, __is, header.ifoff, header.ifsize);
		
		// Read static and instance methods
		MinimizedMethod[] smethods = MinimizedMethod.decodeMethods(
				header.smcount, pool, __is, header.smoff, header.smsize),
			imethods = MinimizedMethod.decodeMethods(
				header.imcount, pool, __is, header.imoff, header.imsize);
		
		throw new todo.TODO();
	}
}

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

11
12
13
14
15
16
17

18
19
20
21
22
23
24
..
88
89
90
91
92
93
94
95


96


























package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.xlate.DataType;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;


/**
 * This represents a field which has been minimized.
 *
 * @since 2019/03/11
 */
public final class MinimizedField
................................................................................
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"Field %s:%s @ %d (%d bytes), flags=%x, value=%s", this.name,
				this.type, this.offset, this.size, this.flags, this.value)));
		
		return rv;
	}
}




































>







 







|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
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
121
122
123
124
125
package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.xlate.DataType;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This represents a field which has been minimized.
 *
 * @since 2019/03/11
 */
public final class MinimizedField
................................................................................
		if (ref == null || null == (rv = ref.get()))
			this._string = new WeakReference<>((rv = String.format(
				"Field %s:%s @ %d (%d bytes), flags=%x, value=%s", this.name,
				this.type, this.offset, this.size, this.flags, this.value)));
		
		return rv;
	}
	
	/**
	 * Decodes the field data.
	 *
	 * @param __n The number of fields.
	 * @param __pool The constant pool.
	 * @param __b Input data.
	 * @param __o Offset into array.
	 * @param __l Length of data rea.
	 * @return The decoded fields.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidClassFormatException If the fields could not be decoded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public static final MinimizedField[] decodeFields(int __n,
		MinimizedPool __pool, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		throw new todo.TODO();
	}
}

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

8
9
10
11
12
13
14

15
16
17
18
19
20
21
..
62
63
64
65
66
67
68
69


70


























// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;

/**
 * This represents a method which has been mimized.
 *
 * @since 2019/03/14
................................................................................
		this.flags = __f;
		this.index = __o;
		this.name = __n;
		this.type = __t;
		this._code = (__tc == null ? new byte[0] : __tc.clone());
		this._lines = (__ln == null ? new byte[0] : __ln.clone());
	}
}




































>







 







|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodName;

/**
 * This represents a method which has been mimized.
 *
 * @since 2019/03/14
................................................................................
		this.flags = __f;
		this.index = __o;
		this.name = __n;
		this.type = __t;
		this._code = (__tc == null ? new byte[0] : __tc.clone());
		this._lines = (__ln == null ? new byte[0] : __ln.clone());
	}
	
	/**
	 * Decodes the method data.
	 *
	 * @param __n The number of methods.
	 * @param __pool The constant pool.
	 * @param __b Input data.
	 * @param __o Offset into array.
	 * @param __l Length of data rea.
	 * @return The decoded methods.
	 * @throws IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidClassFormatException If the methods could not be decoded.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/17
	 */
	public static final MinimizedMethod[] decodeMethods(int __n,
		MinimizedPool __pool, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__b == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		throw new todo.TODO();
	}
}

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

97
98
99
100
101
102
103


104
105
106
107
108
109
110
111

112
113
114
115


116
117
118
119
120
121
122
...
137
138
139
140
141
142
143






144
145
146
147
148
149
150
...
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
	 * 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");


		
		// Types and offsets
		byte[] types = new byte[__n];
		int[] offsets = new int[__n];
		
		// Debug
		todo.DEBUG.note("Decode %d (%d bytes)", __n, __l);
................................................................................
				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];
................................................................................
					
					default:
						throw new todo.OOPS(type.name());
				}
			}
			
			// {@squirreljme.error JC3x Invalid read of pool data.}
			catch (IllegalArgumentException e)
			{
				throw new InvalidClassFormatException("JC3x", e);
			}
			
			// Debug
			todo.DEBUG.note("Read %s", v);
			







>
>


<





>
|



>
>







 







>
>
>
>
>
>







 







|







97
98
99
100
101
102
103
104
105
106
107

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
	 * 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 IndexOutOfBoundsException If the offset and/or length are
	 * negative or exceed the array bounds.
	 * @throws InvalidClassFormatException If the class is not formatted
	 * correctly.

	 * @throws NullPointerException On null arguments.
	 * @since 2019/04/16
	 */
	public static final MinimizedPool decode(int __n, byte[] __is, int __o,
		int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__is == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __is.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Types and offsets
		byte[] types = new byte[__n];
		int[] offsets = new int[__n];
		
		// Debug
		todo.DEBUG.note("Decode %d (%d bytes)", __n, __l);
................................................................................
				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]);
		}
		
		// {@squirreljme.error JC3z Invalid read of pool data.}
		catch (IOException e)
		{
			throw new InvalidClassFormatException("JC3z", e);
		}
		
		// 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];
................................................................................
					
					default:
						throw new todo.OOPS(type.name());
				}
			}
			
			// {@squirreljme.error JC3x Invalid read of pool data.}
			catch (IllegalArgumentException|IOException e)
			{
				throw new InvalidClassFormatException("JC3x", e);
			}
			
			// Debug
			todo.DEBUG.note("Read %s", v);