Check-in [8e5a504986]

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

Overview
Comment:Reading of fields.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8e5a504986c268ba58651dea1126965c49959ec7
User & Date: stephanie.gawroriski 2019-04-17 15:33:11
Context
2019-04-17
15:44
Reading of method data. check-in: 2406898b0e user: stephanie.gawroriski tags: trunk
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

7
8
9
10
11
12
13




14
15

16
17
18
19
20
21
22
..
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












// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

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.
 *
................................................................................
		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();

	}














}

























>
>
>
>


>







 







|











|



|




|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.xlate.DataType;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.FieldDescriptor;
import net.multiphasicapps.classfile.FieldName;
import net.multiphasicapps.classfile.InvalidClassFormatException;

/**
 * This represents a field which has been minimized.
 *
................................................................................
		return rv;
	}
	
	/**
	 * Decodes the field data.
	 *
	 * @param __n The number of fields.
	 * @param __p 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 __p, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__b == null || __p == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Setup return value
		MinimizedField[] rv = new MinimizedField[__n];
		
		// Read field data
		try (DataInputStream dis = new DataInputStream(
			new ByteArrayInputStream(__b, __o, __l)))
		{
			for (int i = 0; i < __n; i++)
			{
				rv[i] = new MinimizedField(
					dis.readInt(),
					dis.readUnsignedShort(),
					dis.readUnsignedShort(),
					new FieldName(
						(String)__p._values[dis.readUnsignedShort()]),
					((ClassName)__p._values[dis.readUnsignedShort()]).field(),
					__p._values[dis.readUnsignedShort()]);
				
				// Data type and padding, the data type here is determined by
				// the field so we do not need to use this pre-calculated
				// value
				dis.readUnsignedByte();
				dis.readUnsignedByte();
			}
		}
		
		// {@squirreljme.error JC40 Could not read field data.}
		catch (ClassCastException|IOException|IndexOutOfBoundsException e)
		{
			throw new InvalidClassFormatException("JC40");
		}
		
		return rv;
	}
}

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

6
7
8
9
10
11
12




13
14
15
16
17
18
19
..
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
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// 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._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();










	}
}








>
>
>
>







 







|











|



|




>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
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
121
122
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
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._lines = (__ln == null ? new byte[0] : __ln.clone());
	}
	
	/**
	 * Decodes the method data.
	 *
	 * @param __n The number of methods.
	 * @param __p 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 __p, byte[] __b, int __o, int __l)
		throws IndexOutOfBoundsException, InvalidClassFormatException,
			NullPointerException
	{
		if (__b == null || __p == null)
			throw new NullPointerException("NARG");
		if (__o < 0 || __l < 0 || (__o + __l) > __b.length)
			throw new IndexOutOfBoundsException("IOOB");
		
		// Setup return value
		MinimizedMethod[] rv = new MinimizedMethod[__n];
		
		// Read method data
		try (DataInputStream dis = new DataInputStream(
			new ByteArrayInputStream(__b, __o, __l)))
		{
			for (int i = 0; i < __n; i++)
			{
				throw new todo.TODO();
			}
		}
		
		// {@squirreljme.error JC41 Could not read method data.}
		catch (ClassCastException|IOException|IndexOutOfBoundsException e)
		{
			throw new InvalidClassFormatException("JC41");
		}
		
		return rv;
	}
}

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

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
	/** Entry types. */
	private final byte[] _types;
	
	/** Parts. */
	private final int[][] _parts;
	
	/** Values. */
	private final Object[] _values;
	
	/**
	 * Initializes the minimized pool.
	 *
	 * @param __ts Types.
	 * @param __ps Parts.
	 * @param __vs Values.







|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
	/** Entry types. */
	private final byte[] _types;
	
	/** Parts. */
	private final int[][] _parts;
	
	/** Values. */
	final Object[] _values;
	
	/**
	 * Initializes the minimized pool.
	 *
	 * @param __ts Types.
	 * @param __ps Parts.
	 * @param __vs Values.