Check-in [2c510e56f3]

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

Overview
Comment:Handling of class info pointer and invoked methods.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2c510e56f3a99d35dcb498cb9c8411d1e6d5263c
User & Date: stephanie.gawroriski 2019-09-11 14:55:47
Context
2019-09-11
15:00
Add a NotedString which is used for the debug entry, it represents a string to be used without needing to make a string object for it. check-in: 503fab114a user: stephanie.gawroriski tags: trunk
14:55
Handling of class info pointer and invoked methods. check-in: 2c510e56f3 user: stephanie.gawroriski tags: trunk
14:36
Correct dual pool encoding and the wrong section offsets being used for normal entry writes. check-in: c6dca51a8d user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

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
...
232
233
234
235
236
237
238


























239
240
241
242
243
244
245
...
252
253
254
255
256
257
258



259
260
261
262
263
264
265
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.BasicPool;
import dev.shadowtail.classfile.pool.BasicPoolBuilder;
import dev.shadowtail.classfile.pool.BasicPoolEntry;

import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;



import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;


import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This contains the encoder and decoder for dual pools.
 *
 * @since 2019/07/17
 */
................................................................................
								
								// Method descriptor, has extra meta-data
							case METHOD_DESCRIPTOR:
								value = new MethodDescriptor(
									entries.get(parts[0]).
									<String>value(String.class));
								break;


























								
								// Unknown
							default:
								throw new todo.OOPS(etype.name());
						}
						break;
						
................................................................................
				entries.add(new BasicPoolEntry(i, value, parts));
				
				// Debug
				todo.DEBUG.note("Entry: ty=%s, np=%d, of=%d(%d), ln=%d --> %s",
					etype, numparts, eoff, baseoff + eoff, elen, value);
			}
			



			// Build pool
			BasicPool result = new BasicPool(entries);
			
			// Store pool in the right spot
			if (isruntime)
				runpool = result;
			else







>


>
>
>




|
|







>
>







 







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







 







>
>
>







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
...
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
...
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
// ---------------------------------------------------------------------------

package dev.shadowtail.classfile.mini;

import dev.shadowtail.classfile.pool.BasicPool;
import dev.shadowtail.classfile.pool.BasicPoolBuilder;
import dev.shadowtail.classfile.pool.BasicPoolEntry;
import dev.shadowtail.classfile.pool.ClassInfoPointer;
import dev.shadowtail.classfile.pool.DualClassRuntimePool;
import dev.shadowtail.classfile.pool.DualClassRuntimePoolBuilder;
import dev.shadowtail.classfile.pool.InvokeType;
import dev.shadowtail.classfile.pool.InvokedMethod;
import dev.shadowtail.classfile.pool.UsedString;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.ClassNames;
import net.multiphasicapps.classfile.InvalidClassFormatException;
import net.multiphasicapps.classfile.MethodDescriptor;
import net.multiphasicapps.classfile.MethodHandle;
import net.multiphasicapps.classfile.MethodName;
import net.multiphasicapps.io.TableSectionOutputStream;

/**
 * This contains the encoder and decoder for dual pools.
 *
 * @since 2019/07/17
 */
................................................................................
								
								// Method descriptor, has extra meta-data
							case METHOD_DESCRIPTOR:
								value = new MethodDescriptor(
									entries.get(parts[0]).
									<String>value(String.class));
								break;
								
								// Class information point
							case CLASS_INFO_POINTER:
								value = new ClassInfoPointer(
									classpool.byIndex(parts[0]).
									<ClassName>value(ClassName.class));
								break;
								
								// A method which has been invoked
							case INVOKED_METHOD:
								value = new InvokedMethod(
									InvokeType.of(parts[0]),
									classpool.<ClassName>byIndex(
										ClassName.class, parts[1]),
									classpool.<String>byIndex(String.class,
										parts[2]),
									classpool.<MethodDescriptor>byIndex(
										MethodDescriptor.class, parts[3]));
								break;
								
								// Used string
							case USED_STRING:
								value = new UsedString(
									classpool.byIndex(parts[0]).
									<String>value(String.class));
								break;
								
								// Unknown
							default:
								throw new todo.OOPS(etype.name());
						}
						break;
						
................................................................................
				entries.add(new BasicPoolEntry(i, value, parts));
				
				// Debug
				todo.DEBUG.note("Entry: ty=%s, np=%d, of=%d(%d), ln=%d --> %s",
					etype, numparts, eoff, baseoff + eoff, elen, value);
			}
			
			// Debug
			todo.DEBUG.note("Entry Count: %d", entries.size());
			
			// Build pool
			BasicPool result = new BasicPool(entries);
			
			// Store pool in the right spot
			if (isruntime)
				runpool = result;
			else

Changes to runt/libs/tool-classfile/dev/shadowtail/classfile/pool/BasicPool.java.

92
93
94
95
96
97
98





















99
100
101
102
103
104
105
	 * @since 2019/09/11
	 */
	public final BasicPoolEntry byIndex(int __i)
		throws IndexOutOfBoundsException
	{
		return this._linear.get(__i);
	}





















	
	/**
	 * Gets the pool entry by value.
	 *
	 * @param __v The value to get.
	 * @return The entry or {@code null} if it was not found.
	 * @since 2019/09/11







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







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
126
	 * @since 2019/09/11
	 */
	public final BasicPoolEntry byIndex(int __i)
		throws IndexOutOfBoundsException
	{
		return this._linear.get(__i);
	}
	
	/**
	 * Gets the pool value by index.
	 *
	 * @param <T> The class type.
	 * @param __cl The class type.
	 * @param __i The index to get.
	 * @return The index of the given entry.
	 * @throws IndexOutOfBoundsException If the entry is not within bounds.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public final <T> T byIndex(Class<T> __cl, int __i)
		throws ClassCastException, IndexOutOfBoundsException,
			NullPointerException
	{
		if (__cl == null)
			throw new NullPointerException("NARG");
		
		return this.byIndex(__i).<T>value(__cl);
	}
	
	/**
	 * Gets the pool entry by value.
	 *
	 * @param __v The value to get.
	 * @return The entry or {@code null} if it was not found.
	 * @since 2019/09/11

Changes to runt/libs/tool-classfile/dev/shadowtail/classfile/pool/InvokedMethod.java.

45
46
47
48
49
50
51





















































52
53
54
55
56
57
58
	 */
	public InvokedMethod(InvokeType __t, String __cl, String __mn, String __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(new ClassName(__cl),
			new MethodName(__mn), new MethodDescriptor(__mt)));
	}





















































	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __h The handle of the method.
	 * @throws NullPointerException On null arguments.







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







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
	 */
	public InvokedMethod(InvokeType __t, String __cl, String __mn, String __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(new ClassName(__cl),
			new MethodName(__mn), new MethodDescriptor(__mt)));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public InvokedMethod(InvokeType __t, ClassName __cl,
		String __mn, String __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(__cl,
			new MethodName(__mn), new MethodDescriptor(__mt)));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public InvokedMethod(InvokeType __t, ClassName __cl,
		String __mn, MethodDescriptor __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(__cl,
			new MethodName(__mn), __mt));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __cl The class.
	 * @param __mn The method name.
	 * @param __mt The method type.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/09/11
	 */
	public InvokedMethod(InvokeType __t, ClassName __cl, MethodName __mn,
		MethodDescriptor __mt)
		throws NullPointerException
	{
		this(__t, new MethodHandle(__cl, __mn, __mt));
	}
	
	/**
	 * Initializes the invoked method.
	 *
	 * @param __t The type of method to invoke.
	 * @param __h The handle of the method.
	 * @throws NullPointerException On null arguments.