Check-in [2406898b0e]

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

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

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

102
103
104
105
106
107
108
109






























110
111
112
113
114
115
116
117
118
119
120
121
122
		
		// 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;
	}
}








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













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
		
		// Read method data
		try (DataInputStream dis = new DataInputStream(
			new ByteArrayInputStream(__b, __o, __l)))
		{
			for (int i = 0; i < __n; i++)
			{
				// Read in method information
				int flags = dis.readInt(),
					offset = dis.readUnsignedShort();
				MethodName name = new MethodName(
					(String)__p._values[dis.readUnsignedShort()]);
				MethodDescriptor type =
					(MethodDescriptor)__p._values[dis.readUnsignedShort()];
				int offcode = dis.readUnsignedShort(), 
					lencode = dis.readUnsignedShort(),
					offline = dis.readUnsignedShort(),
					lenline = dis.readUnsignedShort();
				
				// Read code?
				byte[] code = null;
				if (offcode > 0)
				{
					code = new byte[lencode];
					System.arraycopy(__b, offcode, code, 0, lencode);
				}
				
				// Read lines?
				byte[] line = null;
				if (offline > 0)
				{
					line = new byte[lenline];
					System.arraycopy(__b, offline, line, 0, lenline);
				}
				
				// Build method
				rv[i] = new MinimizedMethod(flags, offset, name, type,
					code, line);
			}
		}
		
		// {@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/__TempMethods__.java.

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
...
110
111
112
113
114
115
116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131
132
133
			ByteArrayOutputStream dbytes = new ByteArrayOutputStream();
			DataOutputStream ddos = new DataOutputStream(dbytes);
			
			// Needed to filter in lines and code so that they are together
			int count = this._count;
			
			// Merge all the code data
			int[] offcode = new int[count];

			ByteArrayOutputStream cbytes = new ByteArrayOutputStream();
			DataOutputStream cdos = new DataOutputStream(cbytes);
			for (int i = 0; i < count; i++)
			{
				MinimizedMethod m = methods.get(i);
				
				// Ignore if there is no code
				byte[] code = m._code;
				if (code == null)
					continue;
				
				// Offset to this code
				offcode[i] = cdos.size();

				
				// Write all the data
				cdos.write(code);
				
				// Pad with the breakpoint operation
				while ((cdos.size() & 3) != 0)
					cdos.write(0xFF);
			}
			
			// Merge all of the line data
			int[] offline = new int[count];

			ByteArrayOutputStream lbytes = new ByteArrayOutputStream();
			DataOutputStream ldos = new DataOutputStream(lbytes);
			for (int i = 0; i < count; i++)
			{
				MinimizedMethod m = methods.get(i);
				
				// Ignore if there are no lines
				byte[] lines = m._lines;
				if (lines == null)
					continue;
				
				// Offset to these lines
				offline[i] = ldos.size();

				
				// Write all the data
				ldos.write(lines);
				
				// Pad
				while ((ldos.size() & 3) != 0)
					ldos.write(0);
................................................................................
				lineoff = codeoff + ldos.size();
			
			// Write field information
			for (int i = 0; i < count; i++)
			{
				MinimizedMethod m = methods.get(i);
				
				// 16-bytes
				ddos.writeInt(m.flags);
				ddos.writeShort(Minimizer.__checkUShort(m.index));
				ddos.writeShort(Minimizer.__checkUShort(
					__pool.get(m.name.toString())));
				ddos.writeShort(Minimizer.__checkUShort(__pool.get(m.type)));
				ddos.writeShort(Minimizer.__checkUShort(codeoff + offcode[i]));

				ddos.writeShort(Minimizer.__checkUShort(lineoff + offline[i]));
				ddos.writeByte(0);
				ddos.writeByte(0);
			}
			
			// Write end of table
			ddos.writeInt(0xFFFFFFFF);
			
			// Merge in the code and line information
			ddos.write(cbytes.toByteArray());







|
>













>










|
>













>







 







|






>

<
|







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
...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

130
131
132
133
134
135
136
137
			ByteArrayOutputStream dbytes = new ByteArrayOutputStream();
			DataOutputStream ddos = new DataOutputStream(dbytes);
			
			// Needed to filter in lines and code so that they are together
			int count = this._count;
			
			// Merge all the code data
			int[] offcode = new int[count],
				lencode = new int[count];
			ByteArrayOutputStream cbytes = new ByteArrayOutputStream();
			DataOutputStream cdos = new DataOutputStream(cbytes);
			for (int i = 0; i < count; i++)
			{
				MinimizedMethod m = methods.get(i);
				
				// Ignore if there is no code
				byte[] code = m._code;
				if (code == null)
					continue;
				
				// Offset to this code
				offcode[i] = cdos.size();
				lencode[i] = code.length;
				
				// Write all the data
				cdos.write(code);
				
				// Pad with the breakpoint operation
				while ((cdos.size() & 3) != 0)
					cdos.write(0xFF);
			}
			
			// Merge all of the line data
			int[] offline = new int[count],
				lenline = new int[count];
			ByteArrayOutputStream lbytes = new ByteArrayOutputStream();
			DataOutputStream ldos = new DataOutputStream(lbytes);
			for (int i = 0; i < count; i++)
			{
				MinimizedMethod m = methods.get(i);
				
				// Ignore if there are no lines
				byte[] lines = m._lines;
				if (lines == null)
					continue;
				
				// Offset to these lines
				offline[i] = ldos.size();
				lenline[i] = lines.length;
				
				// Write all the data
				ldos.write(lines);
				
				// Pad
				while ((ldos.size() & 3) != 0)
					ldos.write(0);
................................................................................
				lineoff = codeoff + ldos.size();
			
			// Write field information
			for (int i = 0; i < count; i++)
			{
				MinimizedMethod m = methods.get(i);
				
				// 18-bytes
				ddos.writeInt(m.flags);
				ddos.writeShort(Minimizer.__checkUShort(m.index));
				ddos.writeShort(Minimizer.__checkUShort(
					__pool.get(m.name.toString())));
				ddos.writeShort(Minimizer.__checkUShort(__pool.get(m.type)));
				ddos.writeShort(Minimizer.__checkUShort(codeoff + offcode[i]));
				ddos.writeShort(Minimizer.__checkUShort(lencode[i]));
				ddos.writeShort(Minimizer.__checkUShort(lineoff + offline[i]));

				ddos.writeShort(Minimizer.__checkUShort(lenline[i]));
			}
			
			// Write end of table
			ddos.writeInt(0xFFFFFFFF);
			
			// Merge in the code and line information
			ddos.write(cbytes.toByteArray());