View | Details | Raw Unified | Return to bug 247292 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-753 / +738 lines)
Lines 27-33 Link Here
27
import org.eclipse.jdt.internal.compiler.util.Util;
27
import org.eclipse.jdt.internal.compiler.util.Util;
28
28
29
public class CodeStream {
29
public class CodeStream {
30
	public static final boolean DEBUG = false;
31
30
32
	// It will be responsible for the following items.
31
	// It will be responsible for the following items.
33
	// -> Tracking Max Stack.
32
	// -> Tracking Max Stack.
Lines 41-129 Link Here
41
	static LocalVariableBinding[] noLocals = new LocalVariableBinding[LOCALS_INCREMENT];
40
	static LocalVariableBinding[] noLocals = new LocalVariableBinding[LOCALS_INCREMENT];
42
	static LocalVariableBinding[] noVisibleLocals = new LocalVariableBinding[LOCALS_INCREMENT];
41
	static LocalVariableBinding[] noVisibleLocals = new LocalVariableBinding[LOCALS_INCREMENT];
43
	public static final CompilationResult RESTART_IN_WIDE_MODE = new CompilationResult((char[])null, 0, 0, 0);
42
	public static final CompilationResult RESTART_IN_WIDE_MODE = new CompilationResult((char[])null, 0, 0, 0);
44
	/**
43
	
45
	 * This methods searches for an existing entry inside the pcToSourceMap table with a pc equals to @pc.
46
	 * If there is an existing entry it returns -1 (no insertion required).
47
	 * Otherwise it returns the index where the entry for the pc has to be inserted.
48
	 * This is based on the fact that the pcToSourceMap table is sorted according to the pc.
49
	 *
50
	 * @param pcToSourceMap the given pcToSourceMap array
51
	 * @param length the given length
52
	 * @param pc the given pc
53
	 * @return int
54
	 */
55
	public static int insertionIndex(int[] pcToSourceMap, int length, int pc) {
56
		int g = 0;
57
		int d = length - 2;
58
		int m = 0;
59
		while (g <= d) {
60
			m = (g + d) / 2;
61
			// we search only on even indexes
62
			if ((m & 1) != 0) // faster than ((m % 2) != 0)
63
				m--;
64
			int currentPC = pcToSourceMap[m];
65
			if (pc < currentPC) {
66
				d = m - 2;
67
			} else
68
				if (pc > currentPC) {
69
					g = m + 2;
70
				} else {
71
					return -1;
72
				}
73
		}
74
		if (pc < pcToSourceMap[m])
75
			return m;
76
		return m + 2;
77
	}
78
	public static final void sort(int[] tab, int lo0, int hi0, int[] result) {
79
		int lo = lo0;
80
		int hi = hi0;
81
		int mid;
82
		if (hi0 > lo0) {
83
			/* Arbitrarily establishing partition element as the midpoint of
84
			  * the array.
85
			  */
86
			mid = tab[lo0 + (hi0 - lo0) / 2];
87
			// loop through the array until indices cross
88
			while (lo <= hi) {
89
				/* find the first element that is greater than or equal to
90
				 * the partition element starting from the left Index.
91
				 */
92
				while ((lo < hi0) && (tab[lo] < mid))
93
					++lo;
94
				/* find an element that is smaller than or equal to
95
				 * the partition element starting from the right Index.
96
				 */
97
				while ((hi > lo0) && (tab[hi] > mid))
98
					--hi;
99
				// if the indexes have not crossed, swap
100
				if (lo <= hi) {
101
					swap(tab, lo, hi, result);
102
					++lo;
103
					--hi;
104
				}
105
			}
106
			/* If the right index has not reached the left side of array
107
			  * must now sort the left partition.
108
			  */
109
			if (lo0 < hi)
110
				sort(tab, lo0, hi, result);
111
			/* If the left index has not reached the right side of array
112
			  * must now sort the right partition.
113
			  */
114
			if (lo < hi0)
115
				sort(tab, lo, hi0, result);
116
		}
117
	}
118
	private static final void swap(int a[], int i, int j, int result[]) {
119
		int T;
120
		T = a[i];
121
		a[i] = a[j];
122
		a[j] = T;
123
		T = result[j];
124
		result[j] = result[i];
125
		result[i] = T;
126
	}
127
	public int allLocalsCounter;
44
	public int allLocalsCounter;
128
	public byte[] bCodeStream;
45
	public byte[] bCodeStream;
129
	public ClassFile classFile; // The current classfile it is associated to.
46
	public ClassFile classFile; // The current classfile it is associated to.
Lines 139-169 Link Here
139
	public BranchLabel[] labels = new BranchLabel[LABELS_INCREMENT];
56
	public BranchLabel[] labels = new BranchLabel[LABELS_INCREMENT];
140
	public int lastEntryPC; // last entry recorded
57
	public int lastEntryPC; // last entry recorded
141
	public int lastAbruptCompletion; // position of last instruction which abrupts completion: goto/return/athrow
58
	public int lastAbruptCompletion; // position of last instruction which abrupts completion: goto/return/athrow
59
142
	public int[] lineSeparatorPositions;
60
	public int[] lineSeparatorPositions;
143
	// line number of the body start and the body end
61
	// line number of the body start and the body end
144
	public int lineNumberStart;
62
	public int lineNumberStart;
145
	public int lineNumberEnd;
146
63
64
	public int lineNumberEnd;
147
	public LocalVariableBinding[] locals = new LocalVariableBinding[LOCALS_INCREMENT];
65
	public LocalVariableBinding[] locals = new LocalVariableBinding[LOCALS_INCREMENT];
148
	public int maxFieldCount;
66
	public int maxFieldCount;
149
150
	public int maxLocals;
67
	public int maxLocals;
151
	public AbstractMethodDeclaration methodDeclaration;
68
	public AbstractMethodDeclaration methodDeclaration;
152
	public int[] pcToSourceMap = new int[24];
69
	public int[] pcToSourceMap = new int[24];
153
	public int pcToSourceMapSize;
70
	public int pcToSourceMapSize;
154
	public int position; // So when first set can be incremented
71
	public int position; // So when first set can be incremented
155
	public boolean preserveUnusedLocals;
72
	public boolean preserveUnusedLocals;
73
156
	public int stackDepth; // Use Ints to keep from using extra bc when adding
74
	public int stackDepth; // Use Ints to keep from using extra bc when adding
75
157
	public int stackMax; // Use Ints to keep from using extra bc when adding
76
	public int stackMax; // Use Ints to keep from using extra bc when adding
158
	public int startingClassFileOffset; // I need to keep the starting point inside the byte array
77
	public int startingClassFileOffset; // I need to keep the starting point inside the byte array
159
160
	// target level to manage different code generation between different target levels
78
	// target level to manage different code generation between different target levels
161
	protected long targetLevel;
79
	protected long targetLevel;
162
80
163
public LocalVariableBinding[] visibleLocals = new LocalVariableBinding[LOCALS_INCREMENT];
81
	public LocalVariableBinding[] visibleLocals = new LocalVariableBinding[LOCALS_INCREMENT];
164
int visibleLocalsCount;
82
		
165
// to handle goto_w
83
	int visibleLocalsCount;
166
public boolean wideMode = false;
84
	
85
	// to handle goto_w
86
	public boolean wideMode = false;	
87
	
167
public CodeStream(ClassFile givenClassFile) {
88
public CodeStream(ClassFile givenClassFile) {
168
	this.targetLevel = givenClassFile.targetJDK;
89
	this.targetLevel = givenClassFile.targetJDK;
169
	this.generateAttributes = givenClassFile.produceAttributes;
90
	this.generateAttributes = givenClassFile.produceAttributes;
Lines 171-178 Link Here
171
		this.lineSeparatorPositions = givenClassFile.referenceBinding.scope.referenceCompilationUnit().compilationResult.getLineSeparatorPositions();
92
		this.lineSeparatorPositions = givenClassFile.referenceBinding.scope.referenceCompilationUnit().compilationResult.getLineSeparatorPositions();
172
	}
93
	}
173
}
94
}
95
/**
96
 * This methods searches for an existing entry inside the pcToSourceMap table with a pc equals to @pc.
97
 * If there is an existing entry it returns -1 (no insertion required).
98
 * Otherwise it returns the index where the entry for the pc has to be inserted.
99
 * This is based on the fact that the pcToSourceMap table is sorted according to the pc.
100
 *
101
 * @param pcToSourceMap the given pcToSourceMap array
102
 * @param length the given length
103
 * @param pc the given pc
104
 * @return int
105
 */
106
public static int insertionIndex(int[] pcToSourceMap, int length, int pc) {
107
	int g = 0;
108
	int d = length - 2;
109
	int m = 0;
110
	while (g <= d) {
111
		m = (g + d) / 2;
112
		// we search only on even indexes
113
		if ((m & 1) != 0) // faster than ((m % 2) != 0)
114
			m--;
115
		int currentPC = pcToSourceMap[m];
116
		if (pc < currentPC) {
117
			d = m - 2;
118
		} else
119
			if (pc > currentPC) {
120
				g = m + 2;
121
			} else {
122
				return -1;
123
			}
124
	}
125
	if (pc < pcToSourceMap[m])
126
		return m;
127
	return m + 2;
128
}
129
public static final void sort(int[] tab, int lo0, int hi0, int[] result) {
130
	int lo = lo0;
131
	int hi = hi0;
132
	int mid;
133
	if (hi0 > lo0) {
134
		/* Arbitrarily establishing partition element as the midpoint of
135
		  * the array.
136
		  */
137
		mid = tab[lo0 + (hi0 - lo0) / 2];
138
		// loop through the array until indices cross
139
		while (lo <= hi) {
140
			/* find the first element that is greater than or equal to
141
			 * the partition element starting from the left Index.
142
			 */
143
			while ((lo < hi0) && (tab[lo] < mid))
144
				++lo;
145
			/* find an element that is smaller than or equal to
146
			 * the partition element starting from the right Index.
147
			 */
148
			while ((hi > lo0) && (tab[hi] > mid))
149
				--hi;
150
			// if the indexes have not crossed, swap
151
			if (lo <= hi) {
152
				swap(tab, lo, hi, result);
153
				++lo;
154
				--hi;
155
			}
156
		}
157
		/* If the right index has not reached the left side of array
158
		  * must now sort the left partition.
159
		  */
160
		if (lo0 < hi)
161
			sort(tab, lo0, hi, result);
162
		/* If the left index has not reached the right side of array
163
		  * must now sort the right partition.
164
		  */
165
		if (lo < hi0)
166
			sort(tab, lo, hi0, result);
167
	}
168
}
169
170
171
private static final void swap(int a[], int i, int j, int result[]) {
172
	int T;
173
	T = a[i];
174
	a[i] = a[j];
175
	a[j] = T;
176
	T = result[j];
177
	result[j] = result[i];
178
	result[i] = T;
179
}
180
174
public void aaload() {
181
public void aaload() {
175
	if (DEBUG) System.out.println(this.position + "\t\taaload"); //$NON-NLS-1$
176
	this.countLabels = 0;
182
	this.countLabels = 0;
177
	this.stackDepth--;
183
	this.stackDepth--;
178
	if (this.classFileOffset >= this.bCodeStream.length) {
184
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 181-188 Link Here
181
	this.position++;
187
	this.position++;
182
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aaload;
188
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aaload;
183
}
189
}
190
184
public void aastore() {
191
public void aastore() {
185
	if (DEBUG) System.out.println(this.position + "\t\taastore"); //$NON-NLS-1$
186
	this.countLabels = 0;
192
	this.countLabels = 0;
187
	this.stackDepth -= 3;
193
	this.stackDepth -= 3;
188
	if (this.classFileOffset >= this.bCodeStream.length) {
194
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 191-198 Link Here
191
	this.position++;
197
	this.position++;
192
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aastore;
198
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aastore;
193
}
199
}
200
194
public void aconst_null() {
201
public void aconst_null() {
195
	if (DEBUG) System.out.println(this.position + "\t\taconst_null"); //$NON-NLS-1$
196
	this.countLabels = 0;
202
	this.countLabels = 0;
197
	this.stackDepth++;
203
	this.stackDepth++;
198
	if (this.stackDepth > this.stackMax) {
204
	if (this.stackDepth > this.stackMax) {
Lines 204-209 Link Here
204
	this.position++;
210
	this.position++;
205
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aconst_null;
211
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aconst_null;
206
}
212
}
213
207
public void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
214
public void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
208
	// Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect
215
	// Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect
209
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
216
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
Lines 231-241 Link Here
231
		}
238
		}
232
	}
239
	}
233
}
240
}
241
234
public void addLabel(BranchLabel aLabel) {
242
public void addLabel(BranchLabel aLabel) {
235
	if (this.countLabels == this.labels.length)
243
	if (this.countLabels == this.labels.length)
236
		System.arraycopy(this.labels, 0, this.labels = new BranchLabel[this.countLabels + LABELS_INCREMENT], 0, this.countLabels);
244
		System.arraycopy(this.labels, 0, this.labels = new BranchLabel[this.countLabels + LABELS_INCREMENT], 0, this.countLabels);
237
	this.labels[this.countLabels++] = aLabel;
245
	this.labels[this.countLabels++] = aLabel;
238
}
246
}
247
248
public void addVariable(LocalVariableBinding localBinding) {
249
	/* do nothing */
250
}
251
239
public void addVisibleLocalVariable(LocalVariableBinding localBinding) {
252
public void addVisibleLocalVariable(LocalVariableBinding localBinding) {
240
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
253
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
241
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
254
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
Lines 247-257 Link Here
247
	this.visibleLocals[this.visibleLocalsCount++] = localBinding;
260
	this.visibleLocals[this.visibleLocalsCount++] = localBinding;
248
}
261
}
249
262
250
public void addVariable(LocalVariableBinding localBinding) {
251
	/* do nothing */
252
}
253
public void aload(int iArg) {
263
public void aload(int iArg) {
254
	if (DEBUG) System.out.println(this.position + "\t\taload:"+iArg); //$NON-NLS-1$
255
	this.countLabels = 0;
264
	this.countLabels = 0;
256
	this.stackDepth++;
265
	this.stackDepth++;
257
	if (this.stackDepth > this.stackMax)
266
	if (this.stackDepth > this.stackMax)
Lines 277-284 Link Here
277
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
286
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
278
	}
287
	}
279
}
288
}
289
280
public void aload_0() {
290
public void aload_0() {
281
	if (DEBUG) System.out.println(this.position + "\t\taload_0"); //$NON-NLS-1$
282
	this.countLabels = 0;
291
	this.countLabels = 0;
283
	this.stackDepth++;
292
	this.stackDepth++;
284
	if (this.stackDepth > this.stackMax) {
293
	if (this.stackDepth > this.stackMax) {
Lines 293-300 Link Here
293
	this.position++;
302
	this.position++;
294
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_0;
303
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_0;
295
}
304
}
305
296
public void aload_1() {
306
public void aload_1() {
297
	if (DEBUG) System.out.println(this.position + "\t\taload_1"); //$NON-NLS-1$
298
	this.countLabels = 0;
307
	this.countLabels = 0;
299
	this.stackDepth++;
308
	this.stackDepth++;
300
	if (this.stackDepth > this.stackMax)
309
	if (this.stackDepth > this.stackMax)
Lines 308-315 Link Here
308
	this.position++;
317
	this.position++;
309
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_1;
318
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_1;
310
}
319
}
320
311
public void aload_2() {
321
public void aload_2() {
312
	if (DEBUG) System.out.println(this.position + "\t\taload_2"); //$NON-NLS-1$
313
	this.countLabels = 0;
322
	this.countLabels = 0;
314
	this.stackDepth++;
323
	this.stackDepth++;
315
	if (this.stackDepth > this.stackMax)
324
	if (this.stackDepth > this.stackMax)
Lines 323-330 Link Here
323
	this.position++;
332
	this.position++;
324
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_2;
333
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_2;
325
}
334
}
335
326
public void aload_3() {
336
public void aload_3() {
327
	if (DEBUG) System.out.println(this.position + "\t\taload_3"); //$NON-NLS-1$
328
	this.countLabels = 0;
337
	this.countLabels = 0;
329
	this.stackDepth++;
338
	this.stackDepth++;
330
	if (this.stackDepth > this.stackMax)
339
	if (this.stackDepth > this.stackMax)
Lines 338-345 Link Here
338
	this.position++;
347
	this.position++;
339
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_3;
348
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_aload_3;
340
}
349
}
350
341
public void anewarray(TypeBinding typeBinding) {
351
public void anewarray(TypeBinding typeBinding) {
342
	if (DEBUG) System.out.println(this.position + "\t\tanewarray: " + typeBinding); //$NON-NLS-1$
343
	this.countLabels = 0;
352
	this.countLabels = 0;
344
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
353
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
345
		resizeByteArray();
354
		resizeByteArray();
Lines 348-355 Link Here
348
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_anewarray;
357
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_anewarray;
349
	writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
358
	writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
350
}
359
}
360
351
public void areturn() {
361
public void areturn() {
352
	if (DEBUG) System.out.println(this.position + "\t\tareturn"); //$NON-NLS-1$
353
	this.countLabels = 0;
362
	this.countLabels = 0;
354
	this.stackDepth--;
363
	this.stackDepth--;
355
	// the stackDepth should be equal to 0
364
	// the stackDepth should be equal to 0
Lines 360-365 Link Here
360
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_areturn;
369
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_areturn;
361
	this.lastAbruptCompletion = this.position;
370
	this.lastAbruptCompletion = this.position;
362
}
371
}
372
363
public void arrayAt(int typeBindingID) {
373
public void arrayAt(int typeBindingID) {
364
	switch (typeBindingID) {
374
	switch (typeBindingID) {
365
		case TypeIds.T_int :
375
		case TypeIds.T_int :
Lines 388-393 Link Here
388
			aaload();
398
			aaload();
389
	}
399
	}
390
}
400
}
401
391
public void arrayAtPut(int elementTypeID, boolean valueRequired) {
402
public void arrayAtPut(int elementTypeID, boolean valueRequired) {
392
	switch (elementTypeID) {
403
	switch (elementTypeID) {
393
		case TypeIds.T_int :
404
		case TypeIds.T_int :
Lines 432-439 Link Here
432
			aastore();
443
			aastore();
433
	}
444
	}
434
}
445
}
446
435
public void arraylength() {
447
public void arraylength() {
436
	if (DEBUG) System.out.println(this.position + "\t\tarraylength"); //$NON-NLS-1$
437
	this.countLabels = 0;
448
	this.countLabels = 0;
438
	if (this.classFileOffset >= this.bCodeStream.length) {
449
	if (this.classFileOffset >= this.bCodeStream.length) {
439
		resizeByteArray();
450
		resizeByteArray();
Lines 441-448 Link Here
441
	this.position++;
452
	this.position++;
442
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_arraylength;
453
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_arraylength;
443
}
454
}
455
444
public void astore(int iArg) {
456
public void astore(int iArg) {
445
	if (DEBUG) System.out.println(this.position + "\t\tastore:"+iArg); //$NON-NLS-1$
446
	this.countLabels = 0;
457
	this.countLabels = 0;
447
	this.stackDepth--;
458
	this.stackDepth--;
448
	if (this.maxLocals <= iArg) {
459
	if (this.maxLocals <= iArg) {
Lines 465-472 Link Here
465
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
476
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
466
	}
477
	}
467
}
478
}
479
468
public void astore_0() {
480
public void astore_0() {
469
	if (DEBUG) System.out.println(this.position + "\t\tastore_0"); //$NON-NLS-1$
470
	this.countLabels = 0;
481
	this.countLabels = 0;
471
	this.stackDepth--;
482
	this.stackDepth--;
472
	if (this.maxLocals == 0) {
483
	if (this.maxLocals == 0) {
Lines 478-485 Link Here
478
	this.position++;
489
	this.position++;
479
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_0;
490
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_0;
480
}
491
}
492
481
public void astore_1() {
493
public void astore_1() {
482
	if (DEBUG) System.out.println(this.position + "\t\tastore_1"); //$NON-NLS-1$
483
	this.countLabels = 0;
494
	this.countLabels = 0;
484
	this.stackDepth--;
495
	this.stackDepth--;
485
	if (this.maxLocals <= 1) {
496
	if (this.maxLocals <= 1) {
Lines 491-498 Link Here
491
	this.position++;
502
	this.position++;
492
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_1;
503
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_1;
493
}
504
}
505
494
public void astore_2() {
506
public void astore_2() {
495
	if (DEBUG) System.out.println(this.position + "\t\tastore_2"); //$NON-NLS-1$
496
	this.countLabels = 0;
507
	this.countLabels = 0;
497
	this.stackDepth--;
508
	this.stackDepth--;
498
	if (this.maxLocals <= 2) {
509
	if (this.maxLocals <= 2) {
Lines 504-511 Link Here
504
	this.position++;
515
	this.position++;
505
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_2;
516
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_2;
506
}
517
}
518
507
public void astore_3() {
519
public void astore_3() {
508
	if (DEBUG) System.out.println(this.position + "\t\tastore_3"); //$NON-NLS-1$
509
	this.countLabels = 0;
520
	this.countLabels = 0;
510
	this.stackDepth--;
521
	this.stackDepth--;
511
	if (this.maxLocals <= 3) {
522
	if (this.maxLocals <= 3) {
Lines 517-524 Link Here
517
	this.position++;
528
	this.position++;
518
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_3;
529
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_astore_3;
519
}
530
}
531
520
public void athrow() {
532
public void athrow() {
521
	if (DEBUG) System.out.println(this.position + "\t\tathrow"); //$NON-NLS-1$
522
	this.countLabels = 0;
533
	this.countLabels = 0;
523
	this.stackDepth--;
534
	this.stackDepth--;
524
	if (this.classFileOffset >= this.bCodeStream.length) {
535
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 528-535 Link Here
528
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_athrow;
539
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_athrow;
529
	this.lastAbruptCompletion = this.position;
540
	this.lastAbruptCompletion = this.position;
530
}
541
}
542
531
public void baload() {
543
public void baload() {
532
	if (DEBUG) System.out.println(this.position + "\t\tbaload"); //$NON-NLS-1$
533
	this.countLabels = 0;
544
	this.countLabels = 0;
534
	this.stackDepth--;
545
	this.stackDepth--;
535
	if (this.classFileOffset >= this.bCodeStream.length) {
546
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 538-545 Link Here
538
	this.position++;
549
	this.position++;
539
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_baload;
550
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_baload;
540
}
551
}
552
541
public void bastore() {
553
public void bastore() {
542
	if (DEBUG) System.out.println(this.position + "\t\tbastore"); //$NON-NLS-1$
543
	this.countLabels = 0;
554
	this.countLabels = 0;
544
	this.stackDepth -= 3;
555
	this.stackDepth -= 3;
545
	if (this.classFileOffset >= this.bCodeStream.length) {
556
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 548-555 Link Here
548
	this.position++;
559
	this.position++;
549
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_bastore;
560
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_bastore;
550
}
561
}
562
551
public void bipush(byte b) {
563
public void bipush(byte b) {
552
	if (DEBUG) System.out.println(this.position + "\t\tbipush "+b); //$NON-NLS-1$
553
	this.countLabels = 0;
564
	this.countLabels = 0;
554
	this.stackDepth++;
565
	this.stackDepth++;
555
	if (this.stackDepth > this.stackMax)
566
	if (this.stackDepth > this.stackMax)
Lines 561-568 Link Here
561
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_bipush;
572
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_bipush;
562
	this.bCodeStream[this.classFileOffset++] = b;
573
	this.bCodeStream[this.classFileOffset++] = b;
563
}
574
}
575
564
public void caload() {
576
public void caload() {
565
	if (DEBUG) System.out.println(this.position + "\t\tcaload"); //$NON-NLS-1$
566
	this.countLabels = 0;
577
	this.countLabels = 0;
567
	this.stackDepth--;
578
	this.stackDepth--;
568
	if (this.classFileOffset >= this.bCodeStream.length) {
579
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 571-578 Link Here
571
	this.position++;
582
	this.position++;
572
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_caload;
583
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_caload;
573
}
584
}
585
574
public void castore() {
586
public void castore() {
575
	if (DEBUG) System.out.println(this.position + "\t\tcastore"); //$NON-NLS-1$
576
	this.countLabels = 0;
587
	this.countLabels = 0;
577
	this.stackDepth -= 3;
588
	this.stackDepth -= 3;
578
	if (this.classFileOffset >= this.bCodeStream.length) {
589
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 581-586 Link Here
581
	this.position++;
592
	this.position++;
582
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_castore;
593
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_castore;
583
}
594
}
595
584
public void checkcast(int baseId) {
596
public void checkcast(int baseId) {
585
	this.countLabels = 0;
597
	this.countLabels = 0;
586
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
598
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
Lines 614-621 Link Here
614
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangBooleanConstantPoolName));
626
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangBooleanConstantPoolName));
615
	}
627
	}
616
}
628
}
629
617
public void checkcast(TypeBinding typeBinding) {
630
public void checkcast(TypeBinding typeBinding) {
618
	if (DEBUG) System.out.println(this.position + "\t\tcheckcast:"+typeBinding.debugName()); //$NON-NLS-1$
619
	this.countLabels = 0;
631
	this.countLabels = 0;
620
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
632
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
621
		resizeByteArray();
633
		resizeByteArray();
Lines 624-631 Link Here
624
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_checkcast;
636
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_checkcast;
625
	writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
637
	writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
626
}
638
}
639
627
public void d2f() {
640
public void d2f() {
628
	if (DEBUG) System.out.println(this.position + "\t\td2f"); //$NON-NLS-1$
629
	this.countLabels = 0;
641
	this.countLabels = 0;
630
	this.stackDepth--;
642
	this.stackDepth--;
631
	if (this.classFileOffset >= this.bCodeStream.length) {
643
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 634-641 Link Here
634
	this.position++;
646
	this.position++;
635
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_d2f;
647
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_d2f;
636
}
648
}
649
637
public void d2i() {
650
public void d2i() {
638
	if (DEBUG) System.out.println(this.position + "\t\td2i"); //$NON-NLS-1$
639
	this.countLabels = 0;
651
	this.countLabels = 0;
640
	this.stackDepth--;
652
	this.stackDepth--;
641
	if (this.classFileOffset >= this.bCodeStream.length) {
653
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 644-651 Link Here
644
	this.position++;
656
	this.position++;
645
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_d2i;
657
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_d2i;
646
}
658
}
659
647
public void d2l() {
660
public void d2l() {
648
	if (DEBUG) System.out.println(this.position + "\t\td2l"); //$NON-NLS-1$
649
	this.countLabels = 0;
661
	this.countLabels = 0;
650
	if (this.classFileOffset >= this.bCodeStream.length) {
662
	if (this.classFileOffset >= this.bCodeStream.length) {
651
		resizeByteArray();
663
		resizeByteArray();
Lines 653-660 Link Here
653
	this.position++;
665
	this.position++;
654
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_d2l;
666
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_d2l;
655
}
667
}
668
656
public void dadd() {
669
public void dadd() {
657
	if (DEBUG) System.out.println(this.position + "\t\tdadd"); //$NON-NLS-1$
658
	this.countLabels = 0;
670
	this.countLabels = 0;
659
	this.stackDepth -= 2;
671
	this.stackDepth -= 2;
660
	if (this.classFileOffset >= this.bCodeStream.length) {
672
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 663-670 Link Here
663
	this.position++;
675
	this.position++;
664
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dadd;
676
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dadd;
665
}
677
}
678
666
public void daload() {
679
public void daload() {
667
	if (DEBUG) System.out.println(this.position + "\t\tdaload"); //$NON-NLS-1$
668
	this.countLabels = 0;
680
	this.countLabels = 0;
669
	if (this.classFileOffset >= this.bCodeStream.length) {
681
	if (this.classFileOffset >= this.bCodeStream.length) {
670
		resizeByteArray();
682
		resizeByteArray();
Lines 672-679 Link Here
672
	this.position++;
684
	this.position++;
673
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_daload;
685
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_daload;
674
}
686
}
687
675
public void dastore() {
688
public void dastore() {
676
	if (DEBUG) System.out.println(this.position + "\t\tdastore"); //$NON-NLS-1$
677
	this.countLabels = 0;
689
	this.countLabels = 0;
678
	this.stackDepth -= 4;
690
	this.stackDepth -= 4;
679
	if (this.classFileOffset >= this.bCodeStream.length) {
691
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 682-689 Link Here
682
	this.position++;
694
	this.position++;
683
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dastore;
695
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dastore;
684
}
696
}
697
685
public void dcmpg() {
698
public void dcmpg() {
686
	if (DEBUG) System.out.println(this.position + "\t\tdcmpg"); //$NON-NLS-1$
687
	this.countLabels = 0;
699
	this.countLabels = 0;
688
	this.stackDepth -= 3;
700
	this.stackDepth -= 3;
689
	if (this.classFileOffset >= this.bCodeStream.length) {
701
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 692-699 Link Here
692
	this.position++;
704
	this.position++;
693
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dcmpg;
705
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dcmpg;
694
}
706
}
707
695
public void dcmpl() {
708
public void dcmpl() {
696
	if (DEBUG) System.out.println(this.position + "\t\tdcmpl"); //$NON-NLS-1$
697
	this.countLabels = 0;
709
	this.countLabels = 0;
698
	this.stackDepth -= 3;
710
	this.stackDepth -= 3;
699
	if (this.classFileOffset >= this.bCodeStream.length) {
711
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 702-709 Link Here
702
	this.position++;
714
	this.position++;
703
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dcmpl;
715
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dcmpl;
704
}
716
}
717
705
public void dconst_0() {
718
public void dconst_0() {
706
	if (DEBUG) System.out.println(this.position + "\t\tdconst_0"); //$NON-NLS-1$
707
	this.countLabels = 0;
719
	this.countLabels = 0;
708
	this.stackDepth += 2;
720
	this.stackDepth += 2;
709
	if (this.stackDepth > this.stackMax)
721
	if (this.stackDepth > this.stackMax)
Lines 714-721 Link Here
714
	this.position++;
726
	this.position++;
715
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dconst_0;
727
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dconst_0;
716
}
728
}
729
717
public void dconst_1() {
730
public void dconst_1() {
718
	if (DEBUG) System.out.println(this.position + "\t\tdconst_1"); //$NON-NLS-1$
719
	this.countLabels = 0;
731
	this.countLabels = 0;
720
	this.stackDepth += 2;
732
	this.stackDepth += 2;
721
	if (this.stackDepth > this.stackMax)
733
	if (this.stackDepth > this.stackMax)
Lines 726-733 Link Here
726
	this.position++;
738
	this.position++;
727
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dconst_1;
739
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dconst_1;
728
}
740
}
741
729
public void ddiv() {
742
public void ddiv() {
730
	if (DEBUG) System.out.println(this.position + "\t\tddiv"); //$NON-NLS-1$
731
	this.countLabels = 0;
743
	this.countLabels = 0;
732
	this.stackDepth -= 2;
744
	this.stackDepth -= 2;
733
	if (this.classFileOffset >= this.bCodeStream.length) {
745
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 736-746 Link Here
736
	this.position++;
748
	this.position++;
737
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ddiv;
749
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ddiv;
738
}
750
}
751
739
public void decrStackSize(int offset) {
752
public void decrStackSize(int offset) {
740
	this.stackDepth -= offset;
753
	this.stackDepth -= offset;
741
}
754
}
755
742
public void dload(int iArg) {
756
public void dload(int iArg) {
743
	if (DEBUG) System.out.println(this.position + "\t\tdload:"+iArg); //$NON-NLS-1$
744
	this.countLabels = 0;
757
	this.countLabels = 0;
745
	this.stackDepth += 2;
758
	this.stackDepth += 2;
746
	if (this.stackDepth > this.stackMax)
759
	if (this.stackDepth > this.stackMax)
Lines 766-773 Link Here
766
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
779
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
767
	}
780
	}
768
}
781
}
782
769
public void dload_0() {
783
public void dload_0() {
770
	if (DEBUG) System.out.println(this.position + "\t\tdload_0"); //$NON-NLS-1$
771
	this.countLabels = 0;
784
	this.countLabels = 0;
772
	this.stackDepth += 2;
785
	this.stackDepth += 2;
773
	if (this.stackDepth > this.stackMax)
786
	if (this.stackDepth > this.stackMax)
Lines 781-788 Link Here
781
	this.position++;
794
	this.position++;
782
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_0;
795
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_0;
783
}
796
}
797
784
public void dload_1() {
798
public void dload_1() {
785
	if (DEBUG) System.out.println(this.position + "\t\tdload_1"); //$NON-NLS-1$
786
	this.countLabels = 0;
799
	this.countLabels = 0;
787
	this.stackDepth += 2;
800
	this.stackDepth += 2;
788
	if (this.stackDepth > this.stackMax)
801
	if (this.stackDepth > this.stackMax)
Lines 796-803 Link Here
796
	this.position++;
809
	this.position++;
797
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_1;
810
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_1;
798
}
811
}
812
799
public void dload_2() {
813
public void dload_2() {
800
	if (DEBUG) System.out.println(this.position + "\t\tdload_2"); //$NON-NLS-1$
801
	this.countLabels = 0;
814
	this.countLabels = 0;
802
	this.stackDepth += 2;
815
	this.stackDepth += 2;
803
	if (this.stackDepth > this.stackMax)
816
	if (this.stackDepth > this.stackMax)
Lines 811-818 Link Here
811
	this.position++;
824
	this.position++;
812
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_2;
825
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_2;
813
}
826
}
827
814
public void dload_3() {
828
public void dload_3() {
815
	if (DEBUG) System.out.println(this.position + "\t\tdload_3"); //$NON-NLS-1$
816
	this.countLabels = 0;
829
	this.countLabels = 0;
817
	this.stackDepth += 2;
830
	this.stackDepth += 2;
818
	if (this.stackDepth > this.stackMax)
831
	if (this.stackDepth > this.stackMax)
Lines 826-833 Link Here
826
	this.position++;
839
	this.position++;
827
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_3;
840
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dload_3;
828
}
841
}
842
829
public void dmul() {
843
public void dmul() {
830
	if (DEBUG) System.out.println(this.position + "\t\tdmul"); //$NON-NLS-1$
831
	this.countLabels = 0;
844
	this.countLabels = 0;
832
	this.stackDepth -= 2;
845
	this.stackDepth -= 2;
833
	if (this.classFileOffset >= this.bCodeStream.length) {
846
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 836-843 Link Here
836
	this.position++;
849
	this.position++;
837
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dmul;
850
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dmul;
838
}
851
}
852
839
public void dneg() {
853
public void dneg() {
840
	if (DEBUG) System.out.println(this.position + "\t\tdneg"); //$NON-NLS-1$
841
	this.countLabels = 0;
854
	this.countLabels = 0;
842
	if (this.classFileOffset >= this.bCodeStream.length) {
855
	if (this.classFileOffset >= this.bCodeStream.length) {
843
		resizeByteArray();
856
		resizeByteArray();
Lines 845-852 Link Here
845
	this.position++;
858
	this.position++;
846
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dneg;
859
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dneg;
847
}
860
}
861
848
public void drem() {
862
public void drem() {
849
	if (DEBUG) System.out.println(this.position + "\t\tdrem"); //$NON-NLS-1$
850
	this.countLabels = 0;
863
	this.countLabels = 0;
851
	this.stackDepth -= 2;
864
	this.stackDepth -= 2;
852
	if (this.classFileOffset >= this.bCodeStream.length) {
865
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 855-862 Link Here
855
	this.position++;
868
	this.position++;
856
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_drem;
869
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_drem;
857
}
870
}
871
858
public void dreturn() {
872
public void dreturn() {
859
	if (DEBUG) System.out.println(this.position + "\t\tdreturn"); //$NON-NLS-1$
860
	this.countLabels = 0;
873
	this.countLabels = 0;
861
	this.stackDepth -= 2;
874
	this.stackDepth -= 2;
862
	// the stackDepth should be equal to 0
875
	// the stackDepth should be equal to 0
Lines 867-874 Link Here
867
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dreturn;
880
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dreturn;
868
	this.lastAbruptCompletion = this.position;
881
	this.lastAbruptCompletion = this.position;
869
}
882
}
883
870
public void dstore(int iArg) {
884
public void dstore(int iArg) {
871
	if (DEBUG) System.out.println(this.position + "\t\tdstore:"+iArg); //$NON-NLS-1$
872
	this.countLabels = 0;
885
	this.countLabels = 0;
873
	this.stackDepth -= 2;
886
	this.stackDepth -= 2;
874
	if (this.maxLocals <= iArg + 1) {
887
	if (this.maxLocals <= iArg + 1) {
Lines 891-898 Link Here
891
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
904
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
892
	}
905
	}
893
}
906
}
907
894
public void dstore_0() {
908
public void dstore_0() {
895
	if (DEBUG) System.out.println(this.position + "\t\tdstore_0"); //$NON-NLS-1$
896
	this.countLabels = 0;
909
	this.countLabels = 0;
897
	this.stackDepth -= 2;
910
	this.stackDepth -= 2;
898
	if (this.maxLocals < 2) {
911
	if (this.maxLocals < 2) {
Lines 904-911 Link Here
904
	this.position++;
917
	this.position++;
905
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_0;
918
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_0;
906
}
919
}
920
907
public void dstore_1() {
921
public void dstore_1() {
908
	if (DEBUG) System.out.println(this.position + "\t\tdstore_1"); //$NON-NLS-1$
909
	this.countLabels = 0;
922
	this.countLabels = 0;
910
	this.stackDepth -= 2;
923
	this.stackDepth -= 2;
911
	if (this.maxLocals < 3) {
924
	if (this.maxLocals < 3) {
Lines 917-924 Link Here
917
	this.position++;
930
	this.position++;
918
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_1;
931
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_1;
919
}
932
}
933
920
public void dstore_2() {
934
public void dstore_2() {
921
	if (DEBUG) System.out.println(this.position + "\t\tdstore_2"); //$NON-NLS-1$
922
	this.countLabels = 0;
935
	this.countLabels = 0;
923
	this.stackDepth -= 2;
936
	this.stackDepth -= 2;
924
	if (this.maxLocals < 4) {
937
	if (this.maxLocals < 4) {
Lines 930-937 Link Here
930
	this.position++;
943
	this.position++;
931
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_2;
944
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_2;
932
}
945
}
946
933
public void dstore_3() {
947
public void dstore_3() {
934
	if (DEBUG) System.out.println(this.position + "\t\tdstore_3"); //$NON-NLS-1$
935
	this.countLabels = 0;
948
	this.countLabels = 0;
936
	this.stackDepth -= 2;
949
	this.stackDepth -= 2;
937
	if (this.maxLocals < 5) {
950
	if (this.maxLocals < 5) {
Lines 943-950 Link Here
943
	this.position++;
956
	this.position++;
944
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_3;
957
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dstore_3;
945
}
958
}
959
946
public void dsub() {
960
public void dsub() {
947
	if (DEBUG) System.out.println(this.position + "\t\tdsub"); //$NON-NLS-1$
948
	this.countLabels = 0;
961
	this.countLabels = 0;
949
	this.stackDepth -= 2;
962
	this.stackDepth -= 2;
950
	if (this.classFileOffset >= this.bCodeStream.length) {
963
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 953-960 Link Here
953
	this.position++;
966
	this.position++;
954
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dsub;
967
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dsub;
955
}
968
}
969
956
public void dup() {
970
public void dup() {
957
	if (DEBUG) System.out.println(this.position + "\t\tdup"); //$NON-NLS-1$
958
	this.countLabels = 0;
971
	this.countLabels = 0;
959
	this.stackDepth++;
972
	this.stackDepth++;
960
	if (this.stackDepth > this.stackMax) {
973
	if (this.stackDepth > this.stackMax) {
Lines 966-973 Link Here
966
	this.position++;
979
	this.position++;
967
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup;
980
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup;
968
}
981
}
982
969
public void dup_x1() {
983
public void dup_x1() {
970
	if (DEBUG) System.out.println(this.position + "\t\tdup_x1"); //$NON-NLS-1$
971
	this.countLabels = 0;
984
	this.countLabels = 0;
972
	this.stackDepth++;
985
	this.stackDepth++;
973
	if (this.stackDepth > this.stackMax)
986
	if (this.stackDepth > this.stackMax)
Lines 978-985 Link Here
978
	this.position++;
991
	this.position++;
979
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup_x1;
992
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup_x1;
980
}
993
}
994
981
public void dup_x2() {
995
public void dup_x2() {
982
	if (DEBUG) System.out.println(this.position + "\t\tdup_x2"); //$NON-NLS-1$
983
	this.countLabels = 0;
996
	this.countLabels = 0;
984
	this.stackDepth++;
997
	this.stackDepth++;
985
	if (this.stackDepth > this.stackMax)
998
	if (this.stackDepth > this.stackMax)
Lines 990-997 Link Here
990
	this.position++;
1003
	this.position++;
991
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup_x2;
1004
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup_x2;
992
}
1005
}
1006
993
public void dup2() {
1007
public void dup2() {
994
	if (DEBUG) System.out.println(this.position + "\t\tdup2"); //$NON-NLS-1$
995
	this.countLabels = 0;
1008
	this.countLabels = 0;
996
	this.stackDepth += 2;
1009
	this.stackDepth += 2;
997
	if (this.stackDepth > this.stackMax)
1010
	if (this.stackDepth > this.stackMax)
Lines 1002-1009 Link Here
1002
	this.position++;
1015
	this.position++;
1003
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup2;
1016
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup2;
1004
}
1017
}
1018
1005
public void dup2_x1() {
1019
public void dup2_x1() {
1006
	if (DEBUG) System.out.println(this.position + "\t\tdup2_x1"); //$NON-NLS-1$
1007
	this.countLabels = 0;
1020
	this.countLabels = 0;
1008
	this.stackDepth += 2;
1021
	this.stackDepth += 2;
1009
	if (this.stackDepth > this.stackMax)
1022
	if (this.stackDepth > this.stackMax)
Lines 1014-1021 Link Here
1014
	this.position++;
1027
	this.position++;
1015
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup2_x1;
1028
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup2_x1;
1016
}
1029
}
1030
1017
public void dup2_x2() {
1031
public void dup2_x2() {
1018
	if (DEBUG) System.out.println(this.position + "\t\tdup2_x2"); //$NON-NLS-1$
1019
	this.countLabels = 0;
1032
	this.countLabels = 0;
1020
	this.stackDepth += 2;
1033
	this.stackDepth += 2;
1021
	if (this.stackDepth > this.stackMax)
1034
	if (this.stackDepth > this.stackMax)
Lines 1026-1034 Link Here
1026
	this.position++;
1039
	this.position++;
1027
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup2_x2;
1040
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_dup2_x2;
1028
}
1041
}
1042
1029
public void exitUserScope(BlockScope currentScope) {
1043
public void exitUserScope(BlockScope currentScope) {
1030
	// mark all the scope's locals as losing their definite assignment
1044
	// mark all the scope's locals as losing their definite assignment
1031
1032
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
1045
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
1033
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
1046
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
1034
			| ClassFileConstants.ATTR_STACK_MAP)) == 0)
1047
			| ClassFileConstants.ATTR_STACK_MAP)) == 0)
Lines 1049-1054 Link Here
1049
		this.visibleLocals[index--] = null; // this variable is no longer visible afterwards
1062
		this.visibleLocals[index--] = null; // this variable is no longer visible afterwards
1050
	}
1063
	}
1051
}
1064
}
1065
1052
public void exitUserScope(BlockScope currentScope, LocalVariableBinding binding) {
1066
public void exitUserScope(BlockScope currentScope, LocalVariableBinding binding) {
1053
	// mark all the scope's locals as losing their definite assignment
1067
	// mark all the scope's locals as losing their definite assignment
1054
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
1068
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
Lines 1070-1077 Link Here
1070
		this.visibleLocals[index--] = null; // this variable is no longer visible afterwards
1084
		this.visibleLocals[index--] = null; // this variable is no longer visible afterwards
1071
	}
1085
	}
1072
}
1086
}
1087
1073
public void f2d() {
1088
public void f2d() {
1074
	if (DEBUG) System.out.println(this.position + "\t\tf2d"); //$NON-NLS-1$
1075
	this.countLabels = 0;
1089
	this.countLabels = 0;
1076
	this.stackDepth++;
1090
	this.stackDepth++;
1077
	if (this.stackDepth > this.stackMax)
1091
	if (this.stackDepth > this.stackMax)
Lines 1082-1089 Link Here
1082
	this.position++;
1096
	this.position++;
1083
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_f2d;
1097
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_f2d;
1084
}
1098
}
1099
1085
public void f2i() {
1100
public void f2i() {
1086
	if (DEBUG) System.out.println(this.position + "\t\tf2i"); //$NON-NLS-1$
1087
	this.countLabels = 0;
1101
	this.countLabels = 0;
1088
	if (this.classFileOffset >= this.bCodeStream.length) {
1102
	if (this.classFileOffset >= this.bCodeStream.length) {
1089
		resizeByteArray();
1103
		resizeByteArray();
Lines 1091-1098 Link Here
1091
	this.position++;
1105
	this.position++;
1092
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_f2i;
1106
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_f2i;
1093
}
1107
}
1108
1094
public void f2l() {
1109
public void f2l() {
1095
	if (DEBUG) System.out.println(this.position + "\t\tf2l"); //$NON-NLS-1$
1096
	this.countLabels = 0;
1110
	this.countLabels = 0;
1097
	this.stackDepth++;
1111
	this.stackDepth++;
1098
	if (this.stackDepth > this.stackMax)
1112
	if (this.stackDepth > this.stackMax)
Lines 1103-1110 Link Here
1103
	this.position++;
1117
	this.position++;
1104
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_f2l;
1118
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_f2l;
1105
}
1119
}
1120
1106
public void fadd() {
1121
public void fadd() {
1107
	if (DEBUG) System.out.println(this.position + "\t\tfadd"); //$NON-NLS-1$
1108
	this.countLabels = 0;
1122
	this.countLabels = 0;
1109
	this.stackDepth--;
1123
	this.stackDepth--;
1110
	if (this.classFileOffset >= this.bCodeStream.length) {
1124
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 1113-1120 Link Here
1113
	this.position++;
1127
	this.position++;
1114
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fadd;
1128
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fadd;
1115
}
1129
}
1130
1116
public void faload() {
1131
public void faload() {
1117
	if (DEBUG) System.out.println(this.position + "\t\tfaload"); //$NON-NLS-1$
1118
	this.countLabels = 0;
1132
	this.countLabels = 0;
1119
	this.stackDepth--;
1133
	this.stackDepth--;
1120
	if (this.classFileOffset >= this.bCodeStream.length) {
1134
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 1123-1130 Link Here
1123
	this.position++;
1137
	this.position++;
1124
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_faload;
1138
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_faload;
1125
}
1139
}
1140
1126
public void fastore() {
1141
public void fastore() {
1127
	if (DEBUG) System.out.println(this.position + "\t\tfaload"); //$NON-NLS-1$
1128
	this.countLabels = 0;
1142
	this.countLabels = 0;
1129
	this.stackDepth -= 3;
1143
	this.stackDepth -= 3;
1130
	if (this.classFileOffset >= this.bCodeStream.length) {
1144
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 1133-1140 Link Here
1133
	this.position++;
1147
	this.position++;
1134
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fastore;
1148
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fastore;
1135
}
1149
}
1150
1136
public void fcmpg() {
1151
public void fcmpg() {
1137
	if (DEBUG) System.out.println(this.position + "\t\tfcmpg"); //$NON-NLS-1$
1138
	this.countLabels = 0;
1152
	this.countLabels = 0;
1139
	this.stackDepth--;
1153
	this.stackDepth--;
1140
	if (this.classFileOffset >= this.bCodeStream.length) {
1154
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 1143-1150 Link Here
1143
	this.position++;
1157
	this.position++;
1144
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fcmpg;
1158
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fcmpg;
1145
}
1159
}
1160
1146
public void fcmpl() {
1161
public void fcmpl() {
1147
	if (DEBUG) System.out.println(this.position + "\t\tfcmpl"); //$NON-NLS-1$
1148
	this.countLabels = 0;
1162
	this.countLabels = 0;
1149
	this.stackDepth--;
1163
	this.stackDepth--;
1150
	if (this.classFileOffset >= this.bCodeStream.length) {
1164
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 1153-1160 Link Here
1153
	this.position++;
1167
	this.position++;
1154
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fcmpl;
1168
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fcmpl;
1155
}
1169
}
1170
1156
public void fconst_0() {
1171
public void fconst_0() {
1157
	if (DEBUG) System.out.println(this.position + "\t\tfconst_0"); //$NON-NLS-1$
1158
	this.countLabels = 0;
1172
	this.countLabels = 0;
1159
	this.stackDepth++;
1173
	this.stackDepth++;
1160
	if (this.stackDepth > this.stackMax)
1174
	if (this.stackDepth > this.stackMax)
Lines 1165-1172 Link Here
1165
	this.position++;
1179
	this.position++;
1166
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fconst_0;
1180
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fconst_0;
1167
}
1181
}
1182
1168
public void fconst_1() {
1183
public void fconst_1() {
1169
	if (DEBUG) System.out.println(this.position + "\t\tfconst_1"); //$NON-NLS-1$
1170
	this.countLabels = 0;
1184
	this.countLabels = 0;
1171
	this.stackDepth++;
1185
	this.stackDepth++;
1172
	if (this.stackDepth > this.stackMax)
1186
	if (this.stackDepth > this.stackMax)
Lines 1177-1184 Link Here
1177
	this.position++;
1191
	this.position++;
1178
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fconst_1;
1192
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fconst_1;
1179
}
1193
}
1194
1180
public void fconst_2() {
1195
public void fconst_2() {
1181
	if (DEBUG) System.out.println(this.position + "\t\tfconst_2"); //$NON-NLS-1$
1182
	this.countLabels = 0;
1196
	this.countLabels = 0;
1183
	this.stackDepth++;
1197
	this.stackDepth++;
1184
	if (this.stackDepth > this.stackMax)
1198
	if (this.stackDepth > this.stackMax)
Lines 1189-1196 Link Here
1189
	this.position++;
1203
	this.position++;
1190
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fconst_2;
1204
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fconst_2;
1191
}
1205
}
1206
1192
public void fdiv() {
1207
public void fdiv() {
1193
	if (DEBUG) System.out.println(this.position + "\t\tfdiv"); //$NON-NLS-1$
1194
	this.countLabels = 0;
1208
	this.countLabels = 0;
1195
	this.stackDepth--;
1209
	this.stackDepth--;
1196
	if (this.classFileOffset >= this.bCodeStream.length) {
1210
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 1199-1206 Link Here
1199
	this.position++;
1213
	this.position++;
1200
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fdiv;
1214
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fdiv;
1201
}
1215
}
1216
1202
public void fload(int iArg) {
1217
public void fload(int iArg) {
1203
	if (DEBUG) System.out.println(this.position + "\t\tfload:"+iArg); //$NON-NLS-1$
1204
	this.countLabels = 0;
1218
	this.countLabels = 0;
1205
	this.stackDepth++;
1219
	this.stackDepth++;
1206
	if (this.maxLocals <= iArg) {
1220
	if (this.maxLocals <= iArg) {
Lines 1225-1232 Link Here
1225
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
1239
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
1226
	}
1240
	}
1227
}
1241
}
1242
1228
public void fload_0() {
1243
public void fload_0() {
1229
	if (DEBUG) System.out.println(this.position + "\t\tfload_0"); //$NON-NLS-1$
1230
	this.countLabels = 0;
1244
	this.countLabels = 0;
1231
	this.stackDepth++;
1245
	this.stackDepth++;
1232
	if (this.maxLocals == 0) {
1246
	if (this.maxLocals == 0) {
Lines 1240-1247 Link Here
1240
	this.position++;
1254
	this.position++;
1241
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_0;
1255
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_0;
1242
}
1256
}
1257
1243
public void fload_1() {
1258
public void fload_1() {
1244
	if (DEBUG) System.out.println(this.position + "\t\tfload_1"); //$NON-NLS-1$
1245
	this.countLabels = 0;
1259
	this.countLabels = 0;
1246
	this.stackDepth++;
1260
	this.stackDepth++;
1247
	if (this.maxLocals <= 1) {
1261
	if (this.maxLocals <= 1) {
Lines 1255-1262 Link Here
1255
	this.position++;
1269
	this.position++;
1256
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_1;
1270
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_1;
1257
}
1271
}
1272
1258
public void fload_2() {
1273
public void fload_2() {
1259
	if (DEBUG) System.out.println(this.position + "\t\tfload_2"); //$NON-NLS-1$
1260
	this.countLabels = 0;
1274
	this.countLabels = 0;
1261
	this.stackDepth++;
1275
	this.stackDepth++;
1262
	if (this.maxLocals <= 2) {
1276
	if (this.maxLocals <= 2) {
Lines 1270-1277 Link Here
1270
	this.position++;
1284
	this.position++;
1271
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_2;
1285
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_2;
1272
}
1286
}
1287
1273
public void fload_3() {
1288
public void fload_3() {
1274
	if (DEBUG) System.out.println(this.position + "\t\tfload_3"); //$NON-NLS-1$
1275
	this.countLabels = 0;
1289
	this.countLabels = 0;
1276
	this.stackDepth++;
1290
	this.stackDepth++;
1277
	if (this.maxLocals <= 3) {
1291
	if (this.maxLocals <= 3) {
Lines 1285-1292 Link Here
1285
	this.position++;
1299
	this.position++;
1286
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_3;
1300
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fload_3;
1287
}
1301
}
1302
1288
public void fmul() {
1303
public void fmul() {
1289
	if (DEBUG) System.out.println(this.position + "\t\tfmul"); //$NON-NLS-1$
1290
	this.countLabels = 0;
1304
	this.countLabels = 0;
1291
	this.stackDepth--;
1305
	this.stackDepth--;
1292
	if (this.classFileOffset >= this.bCodeStream.length) {
1306
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 1295-1302 Link Here
1295
	this.position++;
1309
	this.position++;
1296
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fmul;
1310
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fmul;
1297
}
1311
}
1312
1298
public void fneg() {
1313
public void fneg() {
1299
	if (DEBUG) System.out.println(this.position + "\t\tfneg"); //$NON-NLS-1$
1300
	this.countLabels = 0;
1314
	this.countLabels = 0;
1301
	if (this.classFileOffset >= this.bCodeStream.length) {
1315
	if (this.classFileOffset >= this.bCodeStream.length) {
1302
		resizeByteArray();
1316
		resizeByteArray();
Lines 1304-1311 Link Here
1304
	this.position++;
1318
	this.position++;
1305
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fneg;
1319
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fneg;
1306
}
1320
}
1321
1307
public void frem() {
1322
public void frem() {
1308
	if (DEBUG) System.out.println(this.position + "\t\tfrem"); //$NON-NLS-1$
1309
	this.countLabels = 0;
1323
	this.countLabels = 0;
1310
	this.stackDepth--;
1324
	this.stackDepth--;
1311
	if (this.classFileOffset >= this.bCodeStream.length) {
1325
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 1314-1321 Link Here
1314
	this.position++;
1328
	this.position++;
1315
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_frem;
1329
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_frem;
1316
}
1330
}
1331
1317
public void freturn() {
1332
public void freturn() {
1318
	if (DEBUG) System.out.println(this.position + "\t\tfreturn"); //$NON-NLS-1$
1319
	this.countLabels = 0;
1333
	this.countLabels = 0;
1320
	this.stackDepth--;
1334
	this.stackDepth--;
1321
	// the stackDepth should be equal to 0
1335
	// the stackDepth should be equal to 0
Lines 1326-1333 Link Here
1326
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_freturn;
1340
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_freturn;
1327
	this.lastAbruptCompletion = this.position;
1341
	this.lastAbruptCompletion = this.position;
1328
}
1342
}
1343
1329
public void fstore(int iArg) {
1344
public void fstore(int iArg) {
1330
	if (DEBUG) System.out.println(this.position + "\t\tfstore:"+iArg); //$NON-NLS-1$
1331
	this.countLabels = 0;
1345
	this.countLabels = 0;
1332
	this.stackDepth--;
1346
	this.stackDepth--;
1333
	if (this.maxLocals <= iArg) {
1347
	if (this.maxLocals <= iArg) {
Lines 1350-1357 Link Here
1350
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
1364
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
1351
	}
1365
	}
1352
}
1366
}
1367
1353
public void fstore_0() {
1368
public void fstore_0() {
1354
	if (DEBUG) System.out.println(this.position + "\t\tfstore_0"); //$NON-NLS-1$
1355
	this.countLabels = 0;
1369
	this.countLabels = 0;
1356
	this.stackDepth--;
1370
	this.stackDepth--;
1357
	if (this.maxLocals == 0) {
1371
	if (this.maxLocals == 0) {
Lines 1363-1370 Link Here
1363
	this.position++;
1377
	this.position++;
1364
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fstore_0;
1378
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fstore_0;
1365
}
1379
}
1380
1366
public void fstore_1() {
1381
public void fstore_1() {
1367
	if (DEBUG) System.out.println(this.position + "\t\tfstore_1"); //$NON-NLS-1$
1368
	this.countLabels = 0;
1382
	this.countLabels = 0;
1369
	this.stackDepth--;
1383
	this.stackDepth--;
1370
	if (this.maxLocals <= 1) {
1384
	if (this.maxLocals <= 1) {
Lines 1376-1383 Link Here
1376
	this.position++;
1390
	this.position++;
1377
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fstore_1;
1391
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fstore_1;
1378
}
1392
}
1393
1379
public void fstore_2() {
1394
public void fstore_2() {
1380
	if (DEBUG) System.out.println(this.position + "\t\tfstore_2"); //$NON-NLS-1$
1381
	this.countLabels = 0;
1395
	this.countLabels = 0;
1382
	this.stackDepth--;
1396
	this.stackDepth--;
1383
	if (this.maxLocals <= 2) {
1397
	if (this.maxLocals <= 2) {
Lines 1389-1396 Link Here
1389
	this.position++;
1403
	this.position++;
1390
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fstore_2;
1404
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fstore_2;
1391
}
1405
}
1406
1392
public void fstore_3() {
1407
public void fstore_3() {
1393
	if (DEBUG) System.out.println(this.position + "\t\tfstore_3"); //$NON-NLS-1$
1394
	this.countLabels = 0;
1408
	this.countLabels = 0;
1395
	this.stackDepth--;
1409
	this.stackDepth--;
1396
	if (this.maxLocals <= 3) {
1410
	if (this.maxLocals <= 3) {
Lines 1404-1410 Link Here
1404
}
1418
}
1405
1419
1406
public void fsub() {
1420
public void fsub() {
1407
	if (DEBUG) System.out.println(this.position + "\t\tfsub"); //$NON-NLS-1$
1408
	this.countLabels = 0;
1421
	this.countLabels = 0;
1409
	this.stackDepth--;
1422
	this.stackDepth--;
1410
	if (this.classFileOffset >= this.bCodeStream.length) {
1423
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 1413-1440 Link Here
1413
	this.position++;
1426
	this.position++;
1414
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fsub;
1427
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_fsub;
1415
}
1428
}
1429
1416
public void generateBoxingConversion(int unboxedTypeID) {
1430
public void generateBoxingConversion(int unboxedTypeID) {
1417
    switch (unboxedTypeID) {
1431
    switch (unboxedTypeID) {
1418
        case TypeIds.T_byte :
1432
        case TypeIds.T_byte :
1419
            if (this.targetLevel >= ClassFileConstants.JDK1_5) {
1433
            if (this.targetLevel >= ClassFileConstants.JDK1_5) {
1420
    			if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Byte.valueOf(byte)"); //$NON-NLS-1$
1421
               // invokestatic: Byte.valueOf(byte)
1434
               // invokestatic: Byte.valueOf(byte)
1422
                invoke(
1435
                invoke(
1423
                    Opcodes.OPC_invokestatic,
1436
                    Opcodes.OPC_invokestatic,
1424
                    1, // argCount
1437
                    1, // receiverAndArgsSize
1425
                    1, // return type size
1438
                    1, // return type size
1426
                    ConstantPool.JavaLangByteConstantPoolName,
1439
                    ConstantPool.JavaLangByteConstantPoolName,
1427
                    ConstantPool.ValueOf,
1440
                    ConstantPool.ValueOf,
1428
                    ConstantPool.byteByteSignature);
1441
                    ConstantPool.byteByteSignature);
1429
            } else {
1442
            } else {
1430
               // new Byte( byte )
1443
               // new Byte( byte )
1431
    			if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Byte(byte)"); //$NON-NLS-1$
1432
                newWrapperFor(unboxedTypeID);
1444
                newWrapperFor(unboxedTypeID);
1433
                dup_x1();
1445
                dup_x1();
1434
                swap();
1446
                swap();
1435
                invoke(
1447
                invoke(
1436
                    Opcodes.OPC_invokespecial,
1448
                    Opcodes.OPC_invokespecial,
1437
                    1, // argCount
1449
                    2, // receiverAndArgsSize
1438
                    0, // return type size
1450
                    0, // return type size
1439
                    ConstantPool.JavaLangByteConstantPoolName,
1451
                    ConstantPool.JavaLangByteConstantPoolName,
1440
                    ConstantPool.Init,
1452
                    ConstantPool.Init,
Lines 1444-1466 Link Here
1444
        case TypeIds.T_short :
1456
        case TypeIds.T_short :
1445
            if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) {
1457
            if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) {
1446
                // invokestatic: Short.valueOf(short)
1458
                // invokestatic: Short.valueOf(short)
1447
    			if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Short.valueOf(short)"); //$NON-NLS-1$
1448
                invoke(
1459
                invoke(
1449
                    Opcodes.OPC_invokestatic,
1460
                    Opcodes.OPC_invokestatic,
1450
                    1, // argCount
1461
                    1, // receiverAndArgsSize
1451
                    1, // return type size
1462
                    1, // return type size
1452
                    ConstantPool.JavaLangShortConstantPoolName,
1463
                    ConstantPool.JavaLangShortConstantPoolName,
1453
                    ConstantPool.ValueOf,
1464
                    ConstantPool.ValueOf,
1454
                    ConstantPool.shortShortSignature);
1465
                    ConstantPool.shortShortSignature);
1455
            } else {
1466
            } else {
1456
                // new Short(short)
1467
                // new Short(short)
1457
            	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Short(short)"); //$NON-NLS-1$
1458
            	newWrapperFor(unboxedTypeID);
1468
            	newWrapperFor(unboxedTypeID);
1459
                dup_x1();
1469
                dup_x1();
1460
                swap();
1470
                swap();
1461
                invoke(
1471
                invoke(
1462
                    Opcodes.OPC_invokespecial,
1472
                    Opcodes.OPC_invokespecial,
1463
                    1, // argCount
1473
                    2, // receiverAndArgsSize
1464
                    0, // return type size
1474
                    0, // return type size
1465
                    ConstantPool.JavaLangShortConstantPoolName,
1475
                    ConstantPool.JavaLangShortConstantPoolName,
1466
                    ConstantPool.Init,
1476
                    ConstantPool.Init,
Lines 1470-1492 Link Here
1470
        case TypeIds.T_char :
1480
        case TypeIds.T_char :
1471
            if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) {
1481
            if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) {
1472
                // invokestatic: Character.valueOf(char)
1482
                // invokestatic: Character.valueOf(char)
1473
            	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Character.valueOf(char)"); //$NON-NLS-1$
1474
                invoke(
1483
                invoke(
1475
                    Opcodes.OPC_invokestatic,
1484
                    Opcodes.OPC_invokestatic,
1476
                    1, // argCount
1485
                    1, // receiverAndArgsSize
1477
                    1, // return type size
1486
                    1, // return type size
1478
                    ConstantPool.JavaLangCharacterConstantPoolName,
1487
                    ConstantPool.JavaLangCharacterConstantPoolName,
1479
                    ConstantPool.ValueOf,
1488
                    ConstantPool.ValueOf,
1480
                    ConstantPool.charCharacterSignature);
1489
                    ConstantPool.charCharacterSignature);
1481
            } else {
1490
            } else {
1482
                // new Char( char )
1491
                // new Char( char )
1483
            	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Character(char)"); //$NON-NLS-1$
1484
                newWrapperFor(unboxedTypeID);
1492
                newWrapperFor(unboxedTypeID);
1485
                dup_x1();
1493
                dup_x1();
1486
                swap();
1494
                swap();
1487
                invoke(
1495
                invoke(
1488
                    Opcodes.OPC_invokespecial,
1496
                    Opcodes.OPC_invokespecial,
1489
                    1, // argCount
1497
                    2, // receiverAndArgsSize
1490
                    0, // return type size
1498
                    0, // return type size
1491
                    ConstantPool.JavaLangCharacterConstantPoolName,
1499
                    ConstantPool.JavaLangCharacterConstantPoolName,
1492
                    ConstantPool.Init,
1500
                    ConstantPool.Init,
Lines 1496-1518 Link Here
1496
        case TypeIds.T_int :
1504
        case TypeIds.T_int :
1497
            if (this.targetLevel >= ClassFileConstants.JDK1_5) {
1505
            if (this.targetLevel >= ClassFileConstants.JDK1_5) {
1498
                // invokestatic: Integer.valueOf(int)
1506
                // invokestatic: Integer.valueOf(int)
1499
            	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Integer.valueOf(int)"); //$NON-NLS-1$
1500
                invoke(
1507
                invoke(
1501
                    Opcodes.OPC_invokestatic,
1508
                    Opcodes.OPC_invokestatic,
1502
                    1, // argCount
1509
                    1, // receiverAndArgsSize
1503
                    1, // return type size
1510
                    1, // return type size
1504
                    ConstantPool.JavaLangIntegerConstantPoolName,
1511
                    ConstantPool.JavaLangIntegerConstantPoolName,
1505
                    ConstantPool.ValueOf,
1512
                    ConstantPool.ValueOf,
1506
                    ConstantPool.IntIntegerSignature);
1513
                    ConstantPool.IntIntegerSignature);
1507
            } else {
1514
            } else {
1508
                // new Integer(int)
1515
                // new Integer(int)
1509
            	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Integer(int)"); //$NON-NLS-1$
1510
                newWrapperFor(unboxedTypeID);
1516
                newWrapperFor(unboxedTypeID);
1511
                dup_x1();
1517
                dup_x1();
1512
                swap();
1518
                swap();
1513
                invoke(
1519
                invoke(
1514
                    Opcodes.OPC_invokespecial,
1520
                    Opcodes.OPC_invokespecial,
1515
                    1, // argCount
1521
                    2, // receiverAndArgsSize
1516
                    0, // return type size
1522
                    0, // return type size
1517
                    ConstantPool.JavaLangIntegerConstantPoolName,
1523
                    ConstantPool.JavaLangIntegerConstantPoolName,
1518
                    ConstantPool.Init,
1524
                    ConstantPool.Init,
Lines 1522-1545 Link Here
1522
        case TypeIds.T_long :
1528
        case TypeIds.T_long :
1523
            if (this.targetLevel >= ClassFileConstants.JDK1_5) {
1529
            if (this.targetLevel >= ClassFileConstants.JDK1_5) {
1524
                // invokestatic: Long.valueOf(long)
1530
                // invokestatic: Long.valueOf(long)
1525
            	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Long.valueOf(long)"); //$NON-NLS-1$
1526
                invoke(
1531
                invoke(
1527
                    Opcodes.OPC_invokestatic,
1532
                    Opcodes.OPC_invokestatic,
1528
                    2, // argCount
1533
                    2, // receiverAndArgsSize
1529
                    1, // return type size
1534
                    1, // return type size
1530
                    ConstantPool.JavaLangLongConstantPoolName,
1535
                    ConstantPool.JavaLangLongConstantPoolName,
1531
                    ConstantPool.ValueOf,
1536
                    ConstantPool.ValueOf,
1532
                    ConstantPool.longLongSignature);
1537
                    ConstantPool.longLongSignature);
1533
            } else {
1538
            } else {
1534
                // new Long( long )
1539
                // new Long( long )
1535
            	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Long(long)"); //$NON-NLS-1$
1536
                newWrapperFor(unboxedTypeID);
1540
                newWrapperFor(unboxedTypeID);
1537
                dup_x2();
1541
                dup_x2();
1538
                dup_x2();
1542
                dup_x2();
1539
                pop();
1543
                pop();
1540
                invoke(
1544
                invoke(
1541
                    Opcodes.OPC_invokespecial,
1545
                    Opcodes.OPC_invokespecial,
1542
                    2, // argCount
1546
                    3, // receiverAndArgsSize
1543
                    0, // return type size
1547
                    0, // return type size
1544
                    ConstantPool.JavaLangLongConstantPoolName,
1548
                    ConstantPool.JavaLangLongConstantPoolName,
1545
                    ConstantPool.Init,
1549
                    ConstantPool.Init,
Lines 1549-1571 Link Here
1549
        case TypeIds.T_float :
1553
        case TypeIds.T_float :
1550
            if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) {
1554
            if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) {
1551
                // invokestatic: Float.valueOf(float)
1555
                // invokestatic: Float.valueOf(float)
1552
            	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Float.valueOf(float)"); //$NON-NLS-1$
1553
                invoke(
1556
                invoke(
1554
                    Opcodes.OPC_invokestatic,
1557
                    Opcodes.OPC_invokestatic,
1555
                    1, // argCount
1558
                    1, // receiverAndArgsSize
1556
                    1, // return type size
1559
                    1, // return type size
1557
                    ConstantPool.JavaLangFloatConstantPoolName,
1560
                    ConstantPool.JavaLangFloatConstantPoolName,
1558
                    ConstantPool.ValueOf,
1561
                    ConstantPool.ValueOf,
1559
                    ConstantPool.floatFloatSignature);
1562
                    ConstantPool.floatFloatSignature);
1560
            } else {
1563
            } else {
1561
                // new Float(float)
1564
                // new Float(float)
1562
            	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Float(float)"); //$NON-NLS-1$
1563
                newWrapperFor(unboxedTypeID);
1565
                newWrapperFor(unboxedTypeID);
1564
                dup_x1();
1566
                dup_x1();
1565
                swap();
1567
                swap();
1566
                invoke(
1568
                invoke(
1567
                    Opcodes.OPC_invokespecial,
1569
                    Opcodes.OPC_invokespecial,
1568
                    1, // argCount
1570
                    2, // receiverAndArgsSize
1569
                    0, // return type size
1571
                    0, // return type size
1570
                    ConstantPool.JavaLangFloatConstantPoolName,
1572
                    ConstantPool.JavaLangFloatConstantPoolName,
1571
                    ConstantPool.Init,
1573
                    ConstantPool.Init,
Lines 1575-1591 Link Here
1575
        case TypeIds.T_double :
1577
        case TypeIds.T_double :
1576
            if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) {
1578
            if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) {
1577
                // invokestatic: Double.valueOf(double)
1579
                // invokestatic: Double.valueOf(double)
1578
            	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Double.valueOf(double)"); //$NON-NLS-1$
1579
                invoke(
1580
                invoke(
1580
                    Opcodes.OPC_invokestatic,
1581
                    Opcodes.OPC_invokestatic,
1581
                    2, // argCount
1582
                    3, // receiverAndArgsSize
1582
                    1, // return type size
1583
                    1, // return type size
1583
                    ConstantPool.JavaLangDoubleConstantPoolName,
1584
                    ConstantPool.JavaLangDoubleConstantPoolName,
1584
                    ConstantPool.ValueOf,
1585
                    ConstantPool.ValueOf,
1585
                    ConstantPool.doubleDoubleSignature);
1586
                    ConstantPool.doubleDoubleSignature);
1586
            } else {
1587
            } else {
1587
                // new Double( double )
1588
                // new Double( double )
1588
            	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Double(double)"); //$NON-NLS-1$
1589
            	newWrapperFor(unboxedTypeID);
1589
            	newWrapperFor(unboxedTypeID);
1590
                dup_x2();
1590
                dup_x2();
1591
                dup_x2();
1591
                dup_x2();
Lines 1593-1599 Link Here
1593
1593
1594
                invoke(
1594
                invoke(
1595
                    Opcodes.OPC_invokespecial,
1595
                    Opcodes.OPC_invokespecial,
1596
                    2, // argCount
1596
                    3, // receiverAndArgsSize
1597
                    0, // return type size
1597
                    0, // return type size
1598
                    ConstantPool.JavaLangDoubleConstantPoolName,
1598
                    ConstantPool.JavaLangDoubleConstantPoolName,
1599
                    ConstantPool.Init,
1599
                    ConstantPool.Init,
Lines 1604-1626 Link Here
1604
        case TypeIds.T_boolean :
1604
        case TypeIds.T_boolean :
1605
            if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) {
1605
            if ( this.targetLevel >= ClassFileConstants.JDK1_5 ) {
1606
                // invokestatic: Boolean.valueOf(boolean)
1606
                // invokestatic: Boolean.valueOf(boolean)
1607
            	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic java.lang.Boolean.valueOf(boolean)"); //$NON-NLS-1$
1608
                invoke(
1607
                invoke(
1609
                    Opcodes.OPC_invokestatic,
1608
                    Opcodes.OPC_invokestatic,
1610
                    1, // argCount
1609
                    1, // receiverAndArgsSize
1611
                    1, // return type size
1610
                    1, // return type size
1612
                    ConstantPool.JavaLangBooleanConstantPoolName,
1611
                    ConstantPool.JavaLangBooleanConstantPoolName,
1613
                    ConstantPool.ValueOf,
1612
                    ConstantPool.ValueOf,
1614
                    ConstantPool.booleanBooleanSignature);
1613
                    ConstantPool.booleanBooleanSignature);
1615
            } else {
1614
            } else {
1616
                // new Boolean(boolean)
1615
                // new Boolean(boolean)
1617
            	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial java.lang.Boolean(boolean)"); //$NON-NLS-1$
1618
                newWrapperFor(unboxedTypeID);
1616
                newWrapperFor(unboxedTypeID);
1619
                dup_x1();
1617
                dup_x1();
1620
                swap();
1618
                swap();
1621
                invoke(
1619
                invoke(
1622
                    Opcodes.OPC_invokespecial,
1620
                    Opcodes.OPC_invokespecial,
1623
                    1, // argCount
1621
                    2, // receiverAndArgsSize
1624
                    0, // return type size
1622
                    0, // return type size
1625
                    ConstantPool.JavaLangBooleanConstantPoolName,
1623
                    ConstantPool.JavaLangBooleanConstantPoolName,
1626
                    ConstantPool.Init,
1624
                    ConstantPool.Init,
Lines 1628-1633 Link Here
1628
            }
1626
            }
1629
    }
1627
    }
1630
}
1628
}
1629
1631
/**
1630
/**
1632
 * Macro for building a class descriptor object
1631
 * Macro for building a class descriptor object
1633
 */
1632
 */
Lines 1636-1642 Link Here
1636
		getTYPE(accessedType.id);
1635
		getTYPE(accessedType.id);
1637
		return;
1636
		return;
1638
	}
1637
	}
1639
1640
	if (this.targetLevel >= ClassFileConstants.JDK1_5) {
1638
	if (this.targetLevel >= ClassFileConstants.JDK1_5) {
1641
		// generation using the new ldc_w bytecode
1639
		// generation using the new ldc_w bytecode
1642
		this.ldc(accessedType);
1640
		this.ldc(accessedType);
Lines 1716-1721 Link Here
1716
		this.stackDepth = savedStackDepth;
1714
		this.stackDepth = savedStackDepth;
1717
	}
1715
	}
1718
}
1716
}
1717
1719
/**
1718
/**
1720
 * This method generates the code attribute bytecode
1719
 * This method generates the code attribute bytecode
1721
 */
1720
 */
Lines 1726-1731 Link Here
1726
	invokeJavaLangErrorConstructor();
1725
	invokeJavaLangErrorConstructor();
1727
	athrow();
1726
	athrow();
1728
}
1727
}
1728
1729
public void generateConstant(Constant constant, int implicitConversionCode) {
1729
public void generateConstant(Constant constant, int implicitConversionCode) {
1730
	int targetTypeID = (implicitConversionCode & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4;
1730
	int targetTypeID = (implicitConversionCode & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4;
1731
	if (targetTypeID == 0) targetTypeID = constant.typeID(); // use default constant type
1731
	if (targetTypeID == 0) targetTypeID = constant.typeID(); // use default constant type
Lines 1762-1767 Link Here
1762
		generateBoxingConversion(targetTypeID);
1762
		generateBoxingConversion(targetTypeID);
1763
	}
1763
	}
1764
}
1764
}
1765
1765
public void generateEmulatedReadAccessForField(FieldBinding fieldBinding) {
1766
public void generateEmulatedReadAccessForField(FieldBinding fieldBinding) {
1766
	generateEmulationForField(fieldBinding);
1767
	generateEmulationForField(fieldBinding);
1767
	// swap  the field with the receiver
1768
	// swap  the field with the receiver
Lines 1771-1779 Link Here
1771
		this.checkcast(fieldBinding.type);
1772
		this.checkcast(fieldBinding.type);
1772
	}
1773
	}
1773
}
1774
}
1775
1774
public void generateEmulatedWriteAccessForField(FieldBinding fieldBinding) {
1776
public void generateEmulatedWriteAccessForField(FieldBinding fieldBinding) {
1775
	invokeJavaLangReflectFieldSetter(fieldBinding.type.id);
1777
	invokeJavaLangReflectFieldSetter(fieldBinding.type.id);
1776
}
1778
}
1779
1777
public void generateEmulationForConstructor(Scope scope, MethodBinding methodBinding) {
1780
public void generateEmulationForConstructor(Scope scope, MethodBinding methodBinding) {
1778
	// leave a java.lang.reflect.Field object on the stack
1781
	// leave a java.lang.reflect.Field object on the stack
1779
	this.ldc(String.valueOf(methodBinding.declaringClass.constantPoolName()).replace('/', '.'));
1782
	this.ldc(String.valueOf(methodBinding.declaringClass.constantPoolName()).replace('/', '.'));
Lines 1817-1822 Link Here
1817
	iconst_1();
1820
	iconst_1();
1818
	invokeAccessibleObjectSetAccessible();
1821
	invokeAccessibleObjectSetAccessible();
1819
}
1822
}
1823
1820
public void generateEmulationForField(FieldBinding fieldBinding) {
1824
public void generateEmulationForField(FieldBinding fieldBinding) {
1821
	// leave a java.lang.reflect.Field object on the stack
1825
	// leave a java.lang.reflect.Field object on the stack
1822
	this.ldc(String.valueOf(fieldBinding.declaringClass.constantPoolName()).replace('/', '.'));
1826
	this.ldc(String.valueOf(fieldBinding.declaringClass.constantPoolName()).replace('/', '.'));
Lines 1827-1832 Link Here
1827
	iconst_1();
1831
	iconst_1();
1828
	invokeAccessibleObjectSetAccessible();
1832
	invokeAccessibleObjectSetAccessible();
1829
}
1833
}
1834
1830
public void generateEmulationForMethod(Scope scope, MethodBinding methodBinding) {
1835
public void generateEmulationForMethod(Scope scope, MethodBinding methodBinding) {
1831
	// leave a java.lang.reflect.Field object on the stack
1836
	// leave a java.lang.reflect.Field object on the stack
1832
	this.ldc(String.valueOf(methodBinding.declaringClass.constantPoolName()).replace('/', '.'));
1837
	this.ldc(String.valueOf(methodBinding.declaringClass.constantPoolName()).replace('/', '.'));
Lines 1871-1876 Link Here
1871
	iconst_1();
1876
	iconst_1();
1872
	invokeAccessibleObjectSetAccessible();
1877
	invokeAccessibleObjectSetAccessible();
1873
}
1878
}
1879
1874
private void generateFieldAccess(byte opcode, int returnTypeSize, char[] declaringClass, char[] name, char[] signature) {
1880
private void generateFieldAccess(byte opcode, int returnTypeSize, char[] declaringClass, char[] name, char[] signature) {
1875
	this.countLabels = 0;
1881
	this.countLabels = 0;
1876
	switch(opcode) {
1882
	switch(opcode) {
Lines 1910-1915 Link Here
1910
	this.bCodeStream[this.classFileOffset++] = opcode;
1916
	this.bCodeStream[this.classFileOffset++] = opcode;
1911
	writeUnsignedShort(this.constantPool.literalIndexForField(declaringClass, name, signature));
1917
	writeUnsignedShort(this.constantPool.literalIndexForField(declaringClass, name, signature));
1912
}
1918
}
1919
1913
private void generateFieldAccess(byte opcode, int returnTypeSize, ReferenceBinding binding, char[] name, TypeBinding type) {
1920
private void generateFieldAccess(byte opcode, int returnTypeSize, ReferenceBinding binding, char[] name, TypeBinding type) {
1914
	if (binding.isNestedType()) {
1921
	if (binding.isNestedType()) {
1915
		this.classFile.recordInnerClasses(binding);
1922
		this.classFile.recordInnerClasses(binding);
Lines 1920-1925 Link Here
1920
	}
1927
	}
1921
	this.generateFieldAccess(opcode, returnTypeSize, binding.constantPoolName(), name, type.signature());
1928
	this.generateFieldAccess(opcode, returnTypeSize, binding.constantPoolName(), name, type.signature());
1922
}
1929
}
1930
1923
/**
1931
/**
1924
 * Generates the sequence of instructions which will perform the conversion of the expression
1932
 * Generates the sequence of instructions which will perform the conversion of the expression
1925
 * on the stack into a different type (e.g. long l = someInt; --> i2l must be inserted).
1933
 * on the stack into a different type (e.g. long l = someInt; --> i2l must be inserted).
Lines 2034-2039 Link Here
2034
		generateBoxingConversion(typeId);
2042
		generateBoxingConversion(typeId);
2035
	}
2043
	}
2036
}
2044
}
2045
2037
public void generateInlinedValue(boolean inlinedValue) {
2046
public void generateInlinedValue(boolean inlinedValue) {
2038
	if (inlinedValue)
2047
	if (inlinedValue)
2039
		iconst_1();
2048
		iconst_1();
Lines 2104-2109 Link Here
2104
			this.ldc(inlinedValue);
2113
			this.ldc(inlinedValue);
2105
	}
2114
	}
2106
}
2115
}
2116
2107
public void generateInlinedValue(double inlinedValue) {
2117
public void generateInlinedValue(double inlinedValue) {
2108
	if (inlinedValue == 0.0) {
2118
	if (inlinedValue == 0.0) {
2109
		if (Double.doubleToLongBits(inlinedValue) != 0L)
2119
		if (Double.doubleToLongBits(inlinedValue) != 0L)
Lines 2118-2123 Link Here
2118
	}
2128
	}
2119
	this.ldc2_w(inlinedValue);
2129
	this.ldc2_w(inlinedValue);
2120
}
2130
}
2131
2121
public void generateInlinedValue(float inlinedValue) {
2132
public void generateInlinedValue(float inlinedValue) {
2122
	if (inlinedValue == 0.0f) {
2133
	if (inlinedValue == 0.0f) {
2123
		if (Float.floatToIntBits(inlinedValue) != 0)
2134
		if (Float.floatToIntBits(inlinedValue) != 0)
Lines 2136-2141 Link Here
2136
	}
2147
	}
2137
	this.ldc(inlinedValue);
2148
	this.ldc(inlinedValue);
2138
}
2149
}
2150
2139
public void generateInlinedValue(int inlinedValue) {
2151
public void generateInlinedValue(int inlinedValue) {
2140
	switch (inlinedValue) {
2152
	switch (inlinedValue) {
2141
		case -1 :
2153
		case -1 :
Lines 2171-2176 Link Here
2171
			this.ldc(inlinedValue);
2183
			this.ldc(inlinedValue);
2172
	}
2184
	}
2173
}
2185
}
2186
2174
public void generateInlinedValue(long inlinedValue) {
2187
public void generateInlinedValue(long inlinedValue) {
2175
	if (inlinedValue == 0) {
2188
	if (inlinedValue == 0) {
2176
		lconst_0();
2189
		lconst_0();
Lines 2182-2187 Link Here
2182
	}
2195
	}
2183
	this.ldc2_w(inlinedValue);
2196
	this.ldc2_w(inlinedValue);
2184
}
2197
}
2198
2185
public void generateInlinedValue(short inlinedValue) {
2199
public void generateInlinedValue(short inlinedValue) {
2186
	switch (inlinedValue) {
2200
	switch (inlinedValue) {
2187
		case -1 :
2201
		case -1 :
Lines 2213-2218 Link Here
2213
			sipush(inlinedValue);
2227
			sipush(inlinedValue);
2214
	}
2228
	}
2215
}
2229
}
2230
2216
public void generateOuterAccess(Object[] mappingSequence, ASTNode invocationSite, Binding target, Scope scope) {
2231
public void generateOuterAccess(Object[] mappingSequence, ASTNode invocationSite, Binding target, Scope scope) {
2217
	if (mappingSequence == null) {
2232
	if (mappingSequence == null) {
2218
		if (target instanceof LocalVariableBinding) {
2233
		if (target instanceof LocalVariableBinding) {
Lines 2245-2256 Link Here
2245
			FieldBinding fieldBinding = (FieldBinding) mappingSequence[i];
2260
			FieldBinding fieldBinding = (FieldBinding) mappingSequence[i];
2246
			getfield(fieldBinding);
2261
			getfield(fieldBinding);
2247
		} else {
2262
		} else {
2248
			invokestatic((MethodBinding) mappingSequence[i]);
2263
			invoke(Opcodes.OPC_invokestatic, (MethodBinding) mappingSequence[i], null /* default declaringClass */);
2249
		}
2264
		}
2250
	}
2265
	}
2251
}
2266
}
2252
public void generateReturnBytecode(Expression expression) {
2253
2267
2268
public void generateReturnBytecode(Expression expression) {
2254
	if (expression == null) {
2269
	if (expression == null) {
2255
		return_();
2270
		return_();
2256
	} else {
2271
	} else {
Lines 2279-2284 Link Here
2279
		}
2294
		}
2280
	}
2295
	}
2281
}
2296
}
2297
2282
/**
2298
/**
2283
 * The equivalent code performs a string conversion:
2299
 * The equivalent code performs a string conversion:
2284
 *
2300
 *
Lines 2308-2320 Link Here
2308
	this.recordPositionsFrom(pc, oper2.sourceStart);
2324
	this.recordPositionsFrom(pc, oper2.sourceStart);
2309
	invokeStringConcatenationToString();
2325
	invokeStringConcatenationToString();
2310
}
2326
}
2327
2311
/**
2328
/**
2312
 * @param accessBinding the access method binding to generate
2329
 * @param accessBinding the access method binding to generate
2313
 */
2330
 */
2314
public void generateSyntheticBodyForConstructorAccess(SyntheticMethodBinding accessBinding) {
2331
public void generateSyntheticBodyForConstructorAccess(SyntheticMethodBinding accessBinding) {
2315
2316
	initializeMaxLocals(accessBinding);
2332
	initializeMaxLocals(accessBinding);
2317
2318
	MethodBinding constructorBinding = accessBinding.targetMethod;
2333
	MethodBinding constructorBinding = accessBinding.targetMethod;
2319
	TypeBinding[] parameters = constructorBinding.parameters;
2334
	TypeBinding[] parameters = constructorBinding.parameters;
2320
	int length = parameters.length;
2335
	int length = parameters.length;
Lines 2359-2367 Link Here
2359
				resolvedPosition++;
2374
				resolvedPosition++;
2360
		}
2375
		}
2361
	}
2376
	}
2362
	invokespecial(constructorBinding);
2377
	invoke(Opcodes.OPC_invokespecial, constructorBinding, null /* default declaringClass */);
2363
	return_();
2378
	return_();
2364
}
2379
}
2380
2365
//static X valueOf(String name) {
2381
//static X valueOf(String name) {
2366
// return (X) Enum.valueOf(X.class, name);
2382
// return (X) Enum.valueOf(X.class, name);
2367
//}
2383
//}
Lines 2374-2379 Link Here
2374
	this.checkcast(declaringClass);
2390
	this.checkcast(declaringClass);
2375
	areturn();
2391
	areturn();
2376
}
2392
}
2393
2377
//static X[] values() {
2394
//static X[] values() {
2378
// X[] values;
2395
// X[] values;
2379
// int length;
2396
// int length;
Lines 2404-2409 Link Here
2404
	aload_2();
2421
	aload_2();
2405
	areturn();
2422
	areturn();
2406
}
2423
}
2424
2407
public void generateSyntheticBodyForFieldReadAccess(SyntheticMethodBinding accessBinding) {
2425
public void generateSyntheticBodyForFieldReadAccess(SyntheticMethodBinding accessBinding) {
2408
	initializeMaxLocals(accessBinding);
2426
	initializeMaxLocals(accessBinding);
2409
	FieldBinding fieldBinding = accessBinding.targetReadField;
2427
	FieldBinding fieldBinding = accessBinding.targetReadField;
Lines 2437-2442 Link Here
2437
			areturn();
2455
			areturn();
2438
	}
2456
	}
2439
}
2457
}
2458
2440
public void generateSyntheticBodyForFieldWriteAccess(SyntheticMethodBinding accessBinding) {
2459
public void generateSyntheticBodyForFieldWriteAccess(SyntheticMethodBinding accessBinding) {
2441
	initializeMaxLocals(accessBinding);
2460
	initializeMaxLocals(accessBinding);
2442
	FieldBinding fieldBinding = accessBinding.targetWriteField;
2461
	FieldBinding fieldBinding = accessBinding.targetWriteField;
Lines 2450-2457 Link Here
2450
	}
2469
	}
2451
	return_();
2470
	return_();
2452
}
2471
}
2453
public void generateSyntheticBodyForMethodAccess(SyntheticMethodBinding accessMethod) {
2454
2472
2473
public void generateSyntheticBodyForMethodAccess(SyntheticMethodBinding accessMethod) {
2455
	initializeMaxLocals(accessMethod);
2474
	initializeMaxLocals(accessMethod);
2456
	MethodBinding targetMethod = accessMethod.targetMethod;
2475
	MethodBinding targetMethod = accessMethod.targetMethod;
2457
	TypeBinding[] parameters = targetMethod.parameters;
2476
	TypeBinding[] parameters = targetMethod.parameters;
Lines 2482-2499 Link Here
2482
			resolvedPosition++;
2501
			resolvedPosition++;
2483
	}
2502
	}
2484
	if (targetMethod.isStatic())
2503
	if (targetMethod.isStatic())
2485
		invokestatic(targetMethod);
2504
		invoke(Opcodes.OPC_invokestatic, targetMethod, null /* default declaringClass */);
2486
	else {
2505
	else {
2487
		if (targetMethod.isConstructor()
2506
		if (targetMethod.isConstructor()
2488
			|| targetMethod.isPrivate()
2507
			|| targetMethod.isPrivate()
2489
			// qualified super "X.super.foo()" targets methods from superclass
2508
			// qualified super "X.super.foo()" targets methods from superclass
2490
			|| accessMethod.purpose == SyntheticMethodBinding.SuperMethodAccess){
2509
			|| accessMethod.purpose == SyntheticMethodBinding.SuperMethodAccess){
2491
			invokespecial(targetMethod);
2510
			invoke(Opcodes.OPC_invokespecial, targetMethod, null /* default declaringClass */);
2492
		} else {
2511
		} else {
2493
			if (targetMethod.declaringClass.isInterface()) { // interface or annotation type
2512
			if (targetMethod.declaringClass.isInterface()) { // interface or annotation type
2494
				invokeinterface(targetMethod);
2513
				invoke(Opcodes.OPC_invokeinterface, targetMethod, null /* default declaringClass */);
2495
			} else {
2514
			} else {
2496
				invokevirtual(targetMethod);
2515
				invoke(Opcodes.OPC_invokevirtual, targetMethod, accessMethod.declaringClass);
2497
			}
2516
			}
2498
		}
2517
		}
2499
	}
2518
	}
Lines 2526-2537 Link Here
2526
			areturn();
2545
			areturn();
2527
	}
2546
	}
2528
}
2547
}
2548
2529
public void generateSyntheticBodyForSwitchTable(SyntheticMethodBinding methodBinding) {
2549
public void generateSyntheticBodyForSwitchTable(SyntheticMethodBinding methodBinding) {
2530
	ClassScope scope = ((SourceTypeBinding)methodBinding.declaringClass).scope;
2550
	ClassScope scope = ((SourceTypeBinding)methodBinding.declaringClass).scope;
2531
	initializeMaxLocals(methodBinding);
2551
	initializeMaxLocals(methodBinding);
2532
	final BranchLabel nullLabel = new BranchLabel(this);
2552
	final BranchLabel nullLabel = new BranchLabel(this);
2533
	FieldBinding syntheticFieldBinding = methodBinding.targetReadField;
2553
	FieldBinding syntheticFieldBinding = methodBinding.targetReadField;
2534
2535
	getstatic(syntheticFieldBinding);
2554
	getstatic(syntheticFieldBinding);
2536
	dup();
2555
	dup();
2537
	ifnull(nullLabel);
2556
	ifnull(nullLabel);
Lines 2576-2591 Link Here
2576
	areturn();
2595
	areturn();
2577
	removeVariable(localVariableBinding);
2596
	removeVariable(localVariableBinding);
2578
}
2597
}
2598
2579
/**
2599
/**
2580
 * Code responsible to generate the suitable code to supply values for the synthetic enclosing
2600
 * Code responsible to generate the suitable code to supply values for the synthetic enclosing
2581
 * instance arguments of a constructor invocation of a nested type.
2601
 * instance arguments of a constructor invocation of a nested type.
2582
 */
2602
 */
2583
public void generateSyntheticEnclosingInstanceValues(
2603
public void generateSyntheticEnclosingInstanceValues(BlockScope currentScope, ReferenceBinding targetType, Expression enclosingInstance, ASTNode invocationSite) {
2584
		BlockScope currentScope,
2585
		ReferenceBinding targetType,
2586
		Expression enclosingInstance,
2587
		ASTNode invocationSite) {
2588
2589
	// supplying enclosing instance for the anonymous type's superclass
2604
	// supplying enclosing instance for the anonymous type's superclass
2590
	ReferenceBinding checkedTargetType = targetType.isAnonymousType() ? (ReferenceBinding)targetType.superclass().erasure() : targetType;
2605
	ReferenceBinding checkedTargetType = targetType.isAnonymousType() ? (ReferenceBinding)targetType.superclass().erasure() : targetType;
2591
	boolean hasExtraEnclosingInstance = enclosingInstance != null;
2606
	boolean hasExtraEnclosingInstance = enclosingInstance != null;
Lines 2641-2653 Link Here
2641
		}
2656
		}
2642
	}
2657
	}
2643
}
2658
}
2659
2644
/**
2660
/**
2645
 * Code responsible to generate the suitable code to supply values for the synthetic outer local
2661
 * Code responsible to generate the suitable code to supply values for the synthetic outer local
2646
 * variable arguments of a constructor invocation of a nested type.
2662
 * variable arguments of a constructor invocation of a nested type.
2647
 * (bug 26122) - synthetic values for outer locals must be passed after user arguments, e.g. new X(i = 1){}
2663
 * (bug 26122) - synthetic values for outer locals must be passed after user arguments, e.g. new X(i = 1){}
2648
 */
2664
 */
2649
public void generateSyntheticOuterArgumentValues(BlockScope currentScope, ReferenceBinding targetType, ASTNode invocationSite) {
2665
public void generateSyntheticOuterArgumentValues(BlockScope currentScope, ReferenceBinding targetType, ASTNode invocationSite) {
2650
2651
	// generate the synthetic outer arguments then
2666
	// generate the synthetic outer arguments then
2652
	SyntheticArgumentBinding syntheticArguments[];
2667
	SyntheticArgumentBinding syntheticArguments[];
2653
	if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) {
2668
	if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) {
Lines 2658-2670 Link Here
2658
		}
2673
		}
2659
	}
2674
	}
2660
}
2675
}
2676
2661
public void generateUnboxingConversion(int unboxedTypeID) {
2677
public void generateUnboxingConversion(int unboxedTypeID) {
2662
	switch (unboxedTypeID) {
2678
	switch (unboxedTypeID) {
2663
		case TypeIds.T_byte :
2679
		case TypeIds.T_byte :
2664
			// invokevirtual: byteValue()
2680
			// invokevirtual: byteValue()
2665
			invoke(
2681
			invoke(
2666
					Opcodes.OPC_invokevirtual,
2682
					Opcodes.OPC_invokevirtual,
2667
					0, // argCount
2683
					1, // receiverAndArgsSize
2668
					1, // return type size
2684
					1, // return type size
2669
					ConstantPool.JavaLangByteConstantPoolName,
2685
					ConstantPool.JavaLangByteConstantPoolName,
2670
					ConstantPool.BYTEVALUE_BYTE_METHOD_NAME,
2686
					ConstantPool.BYTEVALUE_BYTE_METHOD_NAME,
Lines 2674-2680 Link Here
2674
			// invokevirtual: shortValue()
2690
			// invokevirtual: shortValue()
2675
			invoke(
2691
			invoke(
2676
					Opcodes.OPC_invokevirtual,
2692
					Opcodes.OPC_invokevirtual,
2677
					0, // argCount
2693
					1, // receiverAndArgsSize
2678
					1, // return type size
2694
					1, // return type size
2679
					ConstantPool.JavaLangShortConstantPoolName,
2695
					ConstantPool.JavaLangShortConstantPoolName,
2680
					ConstantPool.SHORTVALUE_SHORT_METHOD_NAME,
2696
					ConstantPool.SHORTVALUE_SHORT_METHOD_NAME,
Lines 2684-2690 Link Here
2684
			// invokevirtual: charValue()
2700
			// invokevirtual: charValue()
2685
			invoke(
2701
			invoke(
2686
					Opcodes.OPC_invokevirtual,
2702
					Opcodes.OPC_invokevirtual,
2687
					0, // argCount
2703
					1, // receiverAndArgsSize
2688
					1, // return type size
2704
					1, // return type size
2689
					ConstantPool.JavaLangCharacterConstantPoolName,
2705
					ConstantPool.JavaLangCharacterConstantPoolName,
2690
					ConstantPool.CHARVALUE_CHARACTER_METHOD_NAME,
2706
					ConstantPool.CHARVALUE_CHARACTER_METHOD_NAME,
Lines 2694-2700 Link Here
2694
			// invokevirtual: intValue()
2710
			// invokevirtual: intValue()
2695
			invoke(
2711
			invoke(
2696
					Opcodes.OPC_invokevirtual,
2712
					Opcodes.OPC_invokevirtual,
2697
					0, // argCount
2713
					1, // receiverAndArgsSize
2698
					1, // return type size
2714
					1, // return type size
2699
					ConstantPool.JavaLangIntegerConstantPoolName,
2715
					ConstantPool.JavaLangIntegerConstantPoolName,
2700
					ConstantPool.INTVALUE_INTEGER_METHOD_NAME,
2716
					ConstantPool.INTVALUE_INTEGER_METHOD_NAME,
Lines 2704-2710 Link Here
2704
			// invokevirtual: longValue()
2720
			// invokevirtual: longValue()
2705
			invoke(
2721
			invoke(
2706
					Opcodes.OPC_invokevirtual,
2722
					Opcodes.OPC_invokevirtual,
2707
					0, // argCount
2723
					1, // receiverAndArgsSize
2708
					2, // return type size
2724
					2, // return type size
2709
					ConstantPool.JavaLangLongConstantPoolName,
2725
					ConstantPool.JavaLangLongConstantPoolName,
2710
					ConstantPool.LONGVALUE_LONG_METHOD_NAME,
2726
					ConstantPool.LONGVALUE_LONG_METHOD_NAME,
Lines 2714-2720 Link Here
2714
			// invokevirtual: floatValue()
2730
			// invokevirtual: floatValue()
2715
			invoke(
2731
			invoke(
2716
					Opcodes.OPC_invokevirtual,
2732
					Opcodes.OPC_invokevirtual,
2717
					0, // argCount
2733
					1, // receiverAndArgsSize
2718
					1, // return type size
2734
					1, // return type size
2719
					ConstantPool.JavaLangFloatConstantPoolName,
2735
					ConstantPool.JavaLangFloatConstantPoolName,
2720
					ConstantPool.FLOATVALUE_FLOAT_METHOD_NAME,
2736
					ConstantPool.FLOATVALUE_FLOAT_METHOD_NAME,
Lines 2724-2730 Link Here
2724
			// invokevirtual: doubleValue()
2740
			// invokevirtual: doubleValue()
2725
			invoke(
2741
			invoke(
2726
					Opcodes.OPC_invokevirtual,
2742
					Opcodes.OPC_invokevirtual,
2727
					0, // argCount
2743
					1, // receiverAndArgsSize
2728
					2, // return type size
2744
					2, // return type size
2729
					ConstantPool.JavaLangDoubleConstantPoolName,
2745
					ConstantPool.JavaLangDoubleConstantPoolName,
2730
					ConstantPool.DOUBLEVALUE_DOUBLE_METHOD_NAME,
2746
					ConstantPool.DOUBLEVALUE_DOUBLE_METHOD_NAME,
Lines 2734-2746 Link Here
2734
			// invokevirtual: booleanValue()
2750
			// invokevirtual: booleanValue()
2735
			invoke(
2751
			invoke(
2736
					Opcodes.OPC_invokevirtual,
2752
					Opcodes.OPC_invokevirtual,
2737
					0, // argCount
2753
					1, // receiverAndArgsSize
2738
					1, // return type size
2754
					1, // return type size
2739
					ConstantPool.JavaLangBooleanConstantPoolName,
2755
					ConstantPool.JavaLangBooleanConstantPoolName,
2740
					ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_NAME,
2756
					ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_NAME,
2741
					ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_SIGNATURE);
2757
					ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_SIGNATURE);
2742
	}
2758
	}
2743
}
2759
}
2760
2744
/*
2761
/*
2745
 * Wide conditional branch compare, improved by swapping comparison opcode
2762
 * Wide conditional branch compare, improved by swapping comparison opcode
2746
 *   ifeq WideTarget
2763
 *   ifeq WideTarget
Lines 2760-2772 Link Here
2760
		goto_w(wideTarget);
2777
		goto_w(wideTarget);
2761
		intermediate.place();
2778
		intermediate.place();
2762
}
2779
}
2780
2763
public void getBaseTypeValue(int baseTypeID) {
2781
public void getBaseTypeValue(int baseTypeID) {
2764
	switch (baseTypeID) {
2782
	switch (baseTypeID) {
2765
		case TypeIds.T_byte :
2783
		case TypeIds.T_byte :
2766
			// invokevirtual: byteValue()
2784
			// invokevirtual: byteValue()
2767
			invoke(
2785
			invoke(
2768
					Opcodes.OPC_invokevirtual,
2786
					Opcodes.OPC_invokevirtual,
2769
					0, // argCount
2787
					1, // receiverAndArgsSize
2770
					1, // return type size
2788
					1, // return type size
2771
					ConstantPool.JavaLangByteConstantPoolName,
2789
					ConstantPool.JavaLangByteConstantPoolName,
2772
					ConstantPool.BYTEVALUE_BYTE_METHOD_NAME,
2790
					ConstantPool.BYTEVALUE_BYTE_METHOD_NAME,
Lines 2776-2782 Link Here
2776
			// invokevirtual: shortValue()
2794
			// invokevirtual: shortValue()
2777
			invoke(
2795
			invoke(
2778
					Opcodes.OPC_invokevirtual,
2796
					Opcodes.OPC_invokevirtual,
2779
					0, // argCount
2797
					1, // receiverAndArgsSize
2780
					1, // return type size
2798
					1, // return type size
2781
					ConstantPool.JavaLangShortConstantPoolName,
2799
					ConstantPool.JavaLangShortConstantPoolName,
2782
					ConstantPool.SHORTVALUE_SHORT_METHOD_NAME,
2800
					ConstantPool.SHORTVALUE_SHORT_METHOD_NAME,
Lines 2786-2792 Link Here
2786
			// invokevirtual: charValue()
2804
			// invokevirtual: charValue()
2787
			invoke(
2805
			invoke(
2788
					Opcodes.OPC_invokevirtual,
2806
					Opcodes.OPC_invokevirtual,
2789
					0, // argCount
2807
					1, // receiverAndArgsSize
2790
					1, // return type size
2808
					1, // return type size
2791
					ConstantPool.JavaLangCharacterConstantPoolName,
2809
					ConstantPool.JavaLangCharacterConstantPoolName,
2792
					ConstantPool.CHARVALUE_CHARACTER_METHOD_NAME,
2810
					ConstantPool.CHARVALUE_CHARACTER_METHOD_NAME,
Lines 2796-2802 Link Here
2796
			// invokevirtual: intValue()
2814
			// invokevirtual: intValue()
2797
			invoke(
2815
			invoke(
2798
					Opcodes.OPC_invokevirtual,
2816
					Opcodes.OPC_invokevirtual,
2799
					0, // argCount
2817
					1, // receiverAndArgsSize
2800
					1, // return type size
2818
					1, // return type size
2801
					ConstantPool.JavaLangIntegerConstantPoolName,
2819
					ConstantPool.JavaLangIntegerConstantPoolName,
2802
					ConstantPool.INTVALUE_INTEGER_METHOD_NAME,
2820
					ConstantPool.INTVALUE_INTEGER_METHOD_NAME,
Lines 2806-2812 Link Here
2806
			// invokevirtual: longValue()
2824
			// invokevirtual: longValue()
2807
			invoke(
2825
			invoke(
2808
					Opcodes.OPC_invokevirtual,
2826
					Opcodes.OPC_invokevirtual,
2809
					0, // argCount
2827
					1, // receiverAndArgsSize
2810
					2, // return type size
2828
					2, // return type size
2811
					ConstantPool.JavaLangLongConstantPoolName,
2829
					ConstantPool.JavaLangLongConstantPoolName,
2812
					ConstantPool.LONGVALUE_LONG_METHOD_NAME,
2830
					ConstantPool.LONGVALUE_LONG_METHOD_NAME,
Lines 2816-2822 Link Here
2816
			// invokevirtual: floatValue()
2834
			// invokevirtual: floatValue()
2817
			invoke(
2835
			invoke(
2818
					Opcodes.OPC_invokevirtual,
2836
					Opcodes.OPC_invokevirtual,
2819
					0, // argCount
2837
					1, // receiverAndArgsSize
2820
					1, // return type size
2838
					1, // return type size
2821
					ConstantPool.JavaLangFloatConstantPoolName,
2839
					ConstantPool.JavaLangFloatConstantPoolName,
2822
					ConstantPool.FLOATVALUE_FLOAT_METHOD_NAME,
2840
					ConstantPool.FLOATVALUE_FLOAT_METHOD_NAME,
Lines 2826-2832 Link Here
2826
			// invokevirtual: doubleValue()
2844
			// invokevirtual: doubleValue()
2827
			invoke(
2845
			invoke(
2828
					Opcodes.OPC_invokevirtual,
2846
					Opcodes.OPC_invokevirtual,
2829
					0, // argCount
2847
					1, // receiverAndArgsSize
2830
					2, // return type size
2848
					2, // return type size
2831
					ConstantPool.JavaLangDoubleConstantPoolName,
2849
					ConstantPool.JavaLangDoubleConstantPoolName,
2832
					ConstantPool.DOUBLEVALUE_DOUBLE_METHOD_NAME,
2850
					ConstantPool.DOUBLEVALUE_DOUBLE_METHOD_NAME,
Lines 2836-2855 Link Here
2836
			// invokevirtual: booleanValue()
2854
			// invokevirtual: booleanValue()
2837
			invoke(
2855
			invoke(
2838
					Opcodes.OPC_invokevirtual,
2856
					Opcodes.OPC_invokevirtual,
2839
					0, // argCount
2857
					1, // receiverAndArgsSize
2840
					1, // return type size
2858
					1, // return type size
2841
					ConstantPool.JavaLangBooleanConstantPoolName,
2859
					ConstantPool.JavaLangBooleanConstantPoolName,
2842
					ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_NAME,
2860
					ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_NAME,
2843
					ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_SIGNATURE);
2861
					ConstantPool.BOOLEANVALUE_BOOLEAN_METHOD_SIGNATURE);
2844
	}
2862
	}
2845
}
2863
}
2864
2846
final public byte[] getContents() {
2865
final public byte[] getContents() {
2847
	byte[] contents;
2866
	byte[] contents;
2848
	System.arraycopy(this.bCodeStream, 0, contents = new byte[this.position], 0, this.position);
2867
	System.arraycopy(this.bCodeStream, 0, contents = new byte[this.position], 0, this.position);
2849
	return contents;
2868
	return contents;
2850
}
2869
}
2870
2851
public void getfield(FieldBinding fieldBinding) {
2871
public void getfield(FieldBinding fieldBinding) {
2852
	if (DEBUG) System.out.println(this.position + "\t\tgetfield:"+fieldBinding); //$NON-NLS-1$
2853
	int returnTypeSize = 1;
2872
	int returnTypeSize = 1;
2854
	if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) {
2873
	if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) {
2855
		returnTypeSize = 2;
2874
		returnTypeSize = 2;
Lines 2861-2871 Link Here
2861
			fieldBinding.name,
2880
			fieldBinding.name,
2862
			fieldBinding.type);
2881
			fieldBinding.type);
2863
}
2882
}
2883
2864
protected int getPosition() {
2884
protected int getPosition() {
2865
	return this.position;
2885
	return this.position;
2866
}
2886
}
2887
2867
public void getstatic(FieldBinding fieldBinding) {
2888
public void getstatic(FieldBinding fieldBinding) {
2868
	if (DEBUG) System.out.println(this.position + "\t\tgetstatic:"+fieldBinding); //$NON-NLS-1$
2869
	int returnTypeSize = 1;
2889
	int returnTypeSize = 1;
2870
	if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) {
2890
	if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) {
2871
		returnTypeSize = 2;
2891
		returnTypeSize = 2;
Lines 2877-2888 Link Here
2877
			fieldBinding.name,
2897
			fieldBinding.name,
2878
			fieldBinding.type);
2898
			fieldBinding.type);
2879
}
2899
}
2900
2880
public void getTYPE(int baseTypeID) {
2901
public void getTYPE(int baseTypeID) {
2881
	this.countLabels = 0;
2902
	this.countLabels = 0;
2882
	switch (baseTypeID) {
2903
	switch (baseTypeID) {
2883
		case TypeIds.T_byte :
2904
		case TypeIds.T_byte :
2884
			// getstatic: java.lang.Byte.TYPE
2905
			// getstatic: java.lang.Byte.TYPE
2885
			if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Byte.TYPE"); //$NON-NLS-1$
2886
			generateFieldAccess(
2906
			generateFieldAccess(
2887
					Opcodes.OPC_getstatic,
2907
					Opcodes.OPC_getstatic,
2888
					1,
2908
					1,
Lines 2892-2898 Link Here
2892
			break;
2912
			break;
2893
		case TypeIds.T_short :
2913
		case TypeIds.T_short :
2894
			// getstatic: java.lang.Short.TYPE
2914
			// getstatic: java.lang.Short.TYPE
2895
			if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Short.TYPE"); //$NON-NLS-1$
2896
			generateFieldAccess(
2915
			generateFieldAccess(
2897
					Opcodes.OPC_getstatic,
2916
					Opcodes.OPC_getstatic,
2898
					1,
2917
					1,
Lines 2902-2908 Link Here
2902
			break;
2921
			break;
2903
		case TypeIds.T_char :
2922
		case TypeIds.T_char :
2904
			// getstatic: java.lang.Character.TYPE
2923
			// getstatic: java.lang.Character.TYPE
2905
			if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Character.TYPE"); //$NON-NLS-1$
2906
			generateFieldAccess(
2924
			generateFieldAccess(
2907
					Opcodes.OPC_getstatic,
2925
					Opcodes.OPC_getstatic,
2908
					1,
2926
					1,
Lines 2912-2918 Link Here
2912
			break;
2930
			break;
2913
		case TypeIds.T_int :
2931
		case TypeIds.T_int :
2914
			// getstatic: java.lang.Integer.TYPE
2932
			// getstatic: java.lang.Integer.TYPE
2915
			if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Integer.TYPE"); //$NON-NLS-1$
2916
			generateFieldAccess(
2933
			generateFieldAccess(
2917
					Opcodes.OPC_getstatic,
2934
					Opcodes.OPC_getstatic,
2918
					1,
2935
					1,
Lines 2922-2928 Link Here
2922
			break;
2939
			break;
2923
		case TypeIds.T_long :
2940
		case TypeIds.T_long :
2924
			// getstatic: java.lang.Long.TYPE
2941
			// getstatic: java.lang.Long.TYPE
2925
			if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Long.TYPE"); //$NON-NLS-1$
2926
			generateFieldAccess(
2942
			generateFieldAccess(
2927
					Opcodes.OPC_getstatic,
2943
					Opcodes.OPC_getstatic,
2928
					1,
2944
					1,
Lines 2932-2938 Link Here
2932
			break;
2948
			break;
2933
		case TypeIds.T_float :
2949
		case TypeIds.T_float :
2934
			// getstatic: java.lang.Float.TYPE
2950
			// getstatic: java.lang.Float.TYPE
2935
			if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Float.TYPE"); //$NON-NLS-1$
2936
			generateFieldAccess(
2951
			generateFieldAccess(
2937
					Opcodes.OPC_getstatic,
2952
					Opcodes.OPC_getstatic,
2938
					1,
2953
					1,
Lines 2942-2948 Link Here
2942
			break;
2957
			break;
2943
		case TypeIds.T_double :
2958
		case TypeIds.T_double :
2944
			// getstatic: java.lang.Double.TYPE
2959
			// getstatic: java.lang.Double.TYPE
2945
			if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Double.TYPE"); //$NON-NLS-1$
2946
			generateFieldAccess(
2960
			generateFieldAccess(
2947
					Opcodes.OPC_getstatic,
2961
					Opcodes.OPC_getstatic,
2948
					1,
2962
					1,
Lines 2952-2958 Link Here
2952
			break;
2966
			break;
2953
		case TypeIds.T_boolean :
2967
		case TypeIds.T_boolean :
2954
			// getstatic: java.lang.Boolean.TYPE
2968
			// getstatic: java.lang.Boolean.TYPE
2955
			if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Boolean.TYPE"); //$NON-NLS-1$
2956
			generateFieldAccess(
2969
			generateFieldAccess(
2957
					Opcodes.OPC_getstatic,
2970
					Opcodes.OPC_getstatic,
2958
					1,
2971
					1,
Lines 2962-2968 Link Here
2962
			break;
2975
			break;
2963
		case TypeIds.T_void :
2976
		case TypeIds.T_void :
2964
			// getstatic: java.lang.Void.TYPE
2977
			// getstatic: java.lang.Void.TYPE
2965
			if (DEBUG) System.out.println(this.position + "\t\tgetstatic: java.lang.Void.TYPE"); //$NON-NLS-1$
2966
			generateFieldAccess(
2978
			generateFieldAccess(
2967
					Opcodes.OPC_getstatic,
2979
					Opcodes.OPC_getstatic,
2968
					1,
2980
					1,
Lines 2972-2977 Link Here
2972
			break;
2984
			break;
2973
	}
2985
	}
2974
}
2986
}
2987
2975
/**
2988
/**
2976
 * We didn't call it goto, because there is a conflit with the goto keyword
2989
 * We didn't call it goto, because there is a conflit with the goto keyword
2977
 */
2990
 */
Lines 2980-2999 Link Here
2980
		goto_w(label);
2993
		goto_w(label);
2981
		return;
2994
		return;
2982
	}
2995
	}
2983
	if (DEBUG) System.out.println(this.position + "\t\tgoto:"+label); //$NON-NLS-1$
2984
	if (this.classFileOffset >= this.bCodeStream.length) {
2996
	if (this.classFileOffset >= this.bCodeStream.length) {
2985
		resizeByteArray();
2997
		resizeByteArray();
2986
	}
2998
	}
2987
	boolean chained = inlineForwardReferencesFromLabelsTargeting(label, this.position);
2999
	boolean chained = inlineForwardReferencesFromLabelsTargeting(label, this.position);
2988
	if (DEBUG && chained) {
2989
		if (DEBUG) {
2990
			if (this.lastAbruptCompletion == this.position) {
2991
				System.out.println("\t\t\t\t<branch chaining - goto eliminated : "+this.position+","+label+">");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
2992
			} else {
2993
				System.out.println("\t\t\t\t<branch chaining - goto issued : "+this.position+","+label+">");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
2994
			}
2995
		}
2996
	}
2997
	/*
3000
	/*
2998
	 Possible optimization for code such as:
3001
	 Possible optimization for code such as:
2999
	 public Object foo() {
3002
	 public Object foo() {
Lines 3027-3034 Link Here
3027
	label.branch();
3030
	label.branch();
3028
	this.lastAbruptCompletion = this.position;
3031
	this.lastAbruptCompletion = this.position;
3029
}
3032
}
3033
3030
public void goto_w(BranchLabel label) {
3034
public void goto_w(BranchLabel label) {
3031
	if (DEBUG) System.out.println(this.position + "\t\tgotow:"+label); //$NON-NLS-1$
3032
	if (this.classFileOffset >= this.bCodeStream.length) {
3035
	if (this.classFileOffset >= this.bCodeStream.length) {
3033
		resizeByteArray();
3036
		resizeByteArray();
3034
	}
3037
	}
Lines 3037-3044 Link Here
3037
	label.branchWide();
3040
	label.branchWide();
3038
	this.lastAbruptCompletion = this.position;
3041
	this.lastAbruptCompletion = this.position;
3039
}
3042
}
3043
3040
public void i2b() {
3044
public void i2b() {
3041
	if (DEBUG) System.out.println(this.position + "\t\ti2b"); //$NON-NLS-1$
3042
	this.countLabels = 0;
3045
	this.countLabels = 0;
3043
	if (this.classFileOffset >= this.bCodeStream.length) {
3046
	if (this.classFileOffset >= this.bCodeStream.length) {
3044
		resizeByteArray();
3047
		resizeByteArray();
Lines 3046-3053 Link Here
3046
	this.position++;
3049
	this.position++;
3047
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2b;
3050
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2b;
3048
}
3051
}
3052
3049
public void i2c() {
3053
public void i2c() {
3050
	if (DEBUG) System.out.println(this.position + "\t\ti2c"); //$NON-NLS-1$
3051
	this.countLabels = 0;
3054
	this.countLabels = 0;
3052
	if (this.classFileOffset >= this.bCodeStream.length) {
3055
	if (this.classFileOffset >= this.bCodeStream.length) {
3053
		resizeByteArray();
3056
		resizeByteArray();
Lines 3055-3062 Link Here
3055
	this.position++;
3058
	this.position++;
3056
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2c;
3059
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2c;
3057
}
3060
}
3061
3058
public void i2d() {
3062
public void i2d() {
3059
	if (DEBUG) System.out.println(this.position + "\t\ti2d"); //$NON-NLS-1$
3060
	this.countLabels = 0;
3063
	this.countLabels = 0;
3061
	this.stackDepth++;
3064
	this.stackDepth++;
3062
	if (this.stackDepth > this.stackMax)
3065
	if (this.stackDepth > this.stackMax)
Lines 3067-3074 Link Here
3067
	this.position++;
3070
	this.position++;
3068
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2d;
3071
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2d;
3069
}
3072
}
3073
3070
public void i2f() {
3074
public void i2f() {
3071
	if (DEBUG) System.out.println(this.position + "\t\ti2f"); //$NON-NLS-1$
3072
	this.countLabels = 0;
3075
	this.countLabels = 0;
3073
	if (this.classFileOffset >= this.bCodeStream.length) {
3076
	if (this.classFileOffset >= this.bCodeStream.length) {
3074
		resizeByteArray();
3077
		resizeByteArray();
Lines 3076-3083 Link Here
3076
	this.position++;
3079
	this.position++;
3077
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2f;
3080
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2f;
3078
}
3081
}
3082
3079
public void i2l() {
3083
public void i2l() {
3080
	if (DEBUG) System.out.println(this.position + "\t\ti2l"); //$NON-NLS-1$
3081
	this.countLabels = 0;
3084
	this.countLabels = 0;
3082
	this.stackDepth++;
3085
	this.stackDepth++;
3083
	if (this.stackDepth > this.stackMax)
3086
	if (this.stackDepth > this.stackMax)
Lines 3088-3095 Link Here
3088
	this.position++;
3091
	this.position++;
3089
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2l;
3092
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2l;
3090
}
3093
}
3094
3091
public void i2s() {
3095
public void i2s() {
3092
	if (DEBUG) System.out.println(this.position + "\t\ti2s"); //$NON-NLS-1$
3093
	this.countLabels = 0;
3096
	this.countLabels = 0;
3094
	if (this.classFileOffset >= this.bCodeStream.length) {
3097
	if (this.classFileOffset >= this.bCodeStream.length) {
3095
		resizeByteArray();
3098
		resizeByteArray();
Lines 3097-3104 Link Here
3097
	this.position++;
3100
	this.position++;
3098
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2s;
3101
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_i2s;
3099
}
3102
}
3103
3100
public void iadd() {
3104
public void iadd() {
3101
	if (DEBUG) System.out.println(this.position + "\t\tiadd"); //$NON-NLS-1$
3102
	this.countLabels = 0;
3105
	this.countLabels = 0;
3103
	this.stackDepth--;
3106
	this.stackDepth--;
3104
	if (this.classFileOffset >= this.bCodeStream.length) {
3107
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 3107-3114 Link Here
3107
	this.position++;
3110
	this.position++;
3108
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iadd;
3111
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iadd;
3109
}
3112
}
3113
3110
public void iaload() {
3114
public void iaload() {
3111
	if (DEBUG) System.out.println(this.position + "\t\tiaload"); //$NON-NLS-1$
3112
	this.countLabels = 0;
3115
	this.countLabels = 0;
3113
	this.stackDepth--;
3116
	this.stackDepth--;
3114
	if (this.classFileOffset >= this.bCodeStream.length) {
3117
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 3117-3124 Link Here
3117
	this.position++;
3120
	this.position++;
3118
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iaload;
3121
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iaload;
3119
}
3122
}
3123
3120
public void iand() {
3124
public void iand() {
3121
	if (DEBUG) System.out.println(this.position + "\t\tiand"); //$NON-NLS-1$
3122
	this.countLabels = 0;
3125
	this.countLabels = 0;
3123
	this.stackDepth--;
3126
	this.stackDepth--;
3124
	if (this.classFileOffset >= this.bCodeStream.length) {
3127
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 3127-3134 Link Here
3127
	this.position++;
3130
	this.position++;
3128
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iand;
3131
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iand;
3129
}
3132
}
3133
3130
public void iastore() {
3134
public void iastore() {
3131
	if (DEBUG) System.out.println(this.position + "\t\tiastore"); //$NON-NLS-1$
3132
	this.countLabels = 0;
3135
	this.countLabels = 0;
3133
	this.stackDepth -= 3;
3136
	this.stackDepth -= 3;
3134
	if (this.classFileOffset >= this.bCodeStream.length) {
3137
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 3137-3144 Link Here
3137
	this.position++;
3140
	this.position++;
3138
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iastore;
3141
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iastore;
3139
}
3142
}
3143
3140
public void iconst_0() {
3144
public void iconst_0() {
3141
	if (DEBUG) System.out.println(this.position + "\t\ticonst_0"); //$NON-NLS-1$
3142
	this.countLabels = 0;
3145
	this.countLabels = 0;
3143
	this.stackDepth++;
3146
	this.stackDepth++;
3144
	if (this.stackDepth > this.stackMax)
3147
	if (this.stackDepth > this.stackMax)
Lines 3149-3156 Link Here
3149
	this.position++;
3152
	this.position++;
3150
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_0;
3153
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_0;
3151
}
3154
}
3155
3152
public void iconst_1() {
3156
public void iconst_1() {
3153
	if (DEBUG) System.out.println(this.position + "\t\ticonst_1"); //$NON-NLS-1$
3154
	this.countLabels = 0;
3157
	this.countLabels = 0;
3155
	this.stackDepth++;
3158
	this.stackDepth++;
3156
	if (this.stackDepth > this.stackMax)
3159
	if (this.stackDepth > this.stackMax)
Lines 3161-3168 Link Here
3161
	this.position++;
3164
	this.position++;
3162
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_1;
3165
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_1;
3163
}
3166
}
3167
3164
public void iconst_2() {
3168
public void iconst_2() {
3165
	if (DEBUG) System.out.println(this.position + "\t\ticonst_2"); //$NON-NLS-1$
3166
	this.countLabels = 0;
3169
	this.countLabels = 0;
3167
	this.stackDepth++;
3170
	this.stackDepth++;
3168
	if (this.stackDepth > this.stackMax)
3171
	if (this.stackDepth > this.stackMax)
Lines 3174-3180 Link Here
3174
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_2;
3177
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_2;
3175
}
3178
}
3176
public void iconst_3() {
3179
public void iconst_3() {
3177
	if (DEBUG) System.out.println(this.position + "\t\ticonst_3"); //$NON-NLS-1$
3178
	this.countLabels = 0;
3180
	this.countLabels = 0;
3179
	this.stackDepth++;
3181
	this.stackDepth++;
3180
	if (this.stackDepth > this.stackMax)
3182
	if (this.stackDepth > this.stackMax)
Lines 3185-3192 Link Here
3185
	this.position++;
3187
	this.position++;
3186
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_3;
3188
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_3;
3187
}
3189
}
3190
3188
public void iconst_4() {
3191
public void iconst_4() {
3189
	if (DEBUG) System.out.println(this.position + "\t\ticonst_4"); //$NON-NLS-1$
3190
	this.countLabels = 0;
3192
	this.countLabels = 0;
3191
	this.stackDepth++;
3193
	this.stackDepth++;
3192
	if (this.stackDepth > this.stackMax)
3194
	if (this.stackDepth > this.stackMax)
Lines 3197-3204 Link Here
3197
	this.position++;
3199
	this.position++;
3198
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_4;
3200
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_4;
3199
}
3201
}
3202
3200
public void iconst_5() {
3203
public void iconst_5() {
3201
	if (DEBUG) System.out.println(this.position + "\t\ticonst_5"); //$NON-NLS-1$
3202
	this.countLabels = 0;
3204
	this.countLabels = 0;
3203
	this.stackDepth++;
3205
	this.stackDepth++;
3204
	if (this.stackDepth > this.stackMax)
3206
	if (this.stackDepth > this.stackMax)
Lines 3209-3216 Link Here
3209
	this.position++;
3211
	this.position++;
3210
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_5;
3212
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_5;
3211
}
3213
}
3214
3212
public void iconst_m1() {
3215
public void iconst_m1() {
3213
	if (DEBUG) System.out.println(this.position + "\t\ticonst_m1"); //$NON-NLS-1$
3214
	this.countLabels = 0;
3216
	this.countLabels = 0;
3215
	this.stackDepth++;
3217
	this.stackDepth++;
3216
	if (this.stackDepth > this.stackMax)
3218
	if (this.stackDepth > this.stackMax)
Lines 3221-3228 Link Here
3221
	this.position++;
3223
	this.position++;
3222
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_m1;
3224
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iconst_m1;
3223
}
3225
}
3226
3224
public void idiv() {
3227
public void idiv() {
3225
	if (DEBUG) System.out.println(this.position + "\t\tidiv"); //$NON-NLS-1$
3226
	this.countLabels = 0;
3228
	this.countLabels = 0;
3227
	this.stackDepth--;
3229
	this.stackDepth--;
3228
	if (this.classFileOffset >= this.bCodeStream.length) {
3230
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 3231-3238 Link Here
3231
	this.position++;
3233
	this.position++;
3232
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_idiv;
3234
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_idiv;
3233
}
3235
}
3236
3234
public void if_acmpeq(BranchLabel lbl) {
3237
public void if_acmpeq(BranchLabel lbl) {
3235
	if (DEBUG) System.out.println(this.position + "\t\tif_acmpeq:"+lbl); //$NON-NLS-1$
3236
	this.countLabels = 0;
3238
	this.countLabels = 0;
3237
	this.stackDepth-=2;
3239
	this.stackDepth-=2;
3238
	if (this.wideMode) {
3240
	if (this.wideMode) {
Lines 3246-3253 Link Here
3246
		lbl.branch();
3248
		lbl.branch();
3247
	}
3249
	}
3248
}
3250
}
3251
3249
public void if_acmpne(BranchLabel lbl) {
3252
public void if_acmpne(BranchLabel lbl) {
3250
	if (DEBUG) System.out.println(this.position + "\t\tif_acmpne:"+lbl); //$NON-NLS-1$
3251
	this.countLabels = 0;
3253
	this.countLabels = 0;
3252
	this.stackDepth-=2;
3254
	this.stackDepth-=2;
3253
	if (this.wideMode) {
3255
	if (this.wideMode) {
Lines 3261-3268 Link Here
3261
		lbl.branch();
3263
		lbl.branch();
3262
	}
3264
	}
3263
}
3265
}
3266
3264
public void if_icmpeq(BranchLabel lbl) {
3267
public void if_icmpeq(BranchLabel lbl) {
3265
	if (DEBUG) System.out.println(this.position + "\t\tif_cmpeq:"+lbl); //$NON-NLS-1$
3266
	this.countLabels = 0;
3268
	this.countLabels = 0;
3267
	this.stackDepth -= 2;
3269
	this.stackDepth -= 2;
3268
	if (this.wideMode) {
3270
	if (this.wideMode) {
Lines 3276-3283 Link Here
3276
		lbl.branch();
3278
		lbl.branch();
3277
	}
3279
	}
3278
}
3280
}
3281
3279
public void if_icmpge(BranchLabel lbl) {
3282
public void if_icmpge(BranchLabel lbl) {
3280
	if (DEBUG) System.out.println(this.position + "\t\tif_icmpge:"+lbl); //$NON-NLS-1$
3281
	this.countLabels = 0;
3283
	this.countLabels = 0;
3282
	this.stackDepth -= 2;
3284
	this.stackDepth -= 2;
3283
	if (this.wideMode) {
3285
	if (this.wideMode) {
Lines 3291-3298 Link Here
3291
		lbl.branch();
3293
		lbl.branch();
3292
	}
3294
	}
3293
}
3295
}
3296
3294
public void if_icmpgt(BranchLabel lbl) {
3297
public void if_icmpgt(BranchLabel lbl) {
3295
	if (DEBUG) System.out.println(this.position + "\t\tif_icmpgt:"+lbl); //$NON-NLS-1$
3296
	this.countLabels = 0;
3298
	this.countLabels = 0;
3297
	this.stackDepth -= 2;
3299
	this.stackDepth -= 2;
3298
	if (this.wideMode) {
3300
	if (this.wideMode) {
Lines 3306-3313 Link Here
3306
		lbl.branch();
3308
		lbl.branch();
3307
	}
3309
	}
3308
}
3310
}
3311
3309
public void if_icmple(BranchLabel lbl) {
3312
public void if_icmple(BranchLabel lbl) {
3310
	if (DEBUG) System.out.println(this.position + "\t\tif_icmple:"+lbl); //$NON-NLS-1$
3311
	this.countLabels = 0;
3313
	this.countLabels = 0;
3312
	this.stackDepth -= 2;
3314
	this.stackDepth -= 2;
3313
	if (this.wideMode) {
3315
	if (this.wideMode) {
Lines 3321-3328 Link Here
3321
		lbl.branch();
3323
		lbl.branch();
3322
	}
3324
	}
3323
}
3325
}
3326
3324
public void if_icmplt(BranchLabel lbl) {
3327
public void if_icmplt(BranchLabel lbl) {
3325
	if (DEBUG) System.out.println(this.position + "\t\tif_icmplt:"+lbl); //$NON-NLS-1$
3326
	this.countLabels = 0;
3328
	this.countLabels = 0;
3327
	this.stackDepth -= 2;
3329
	this.stackDepth -= 2;
3328
	if (this.wideMode) {
3330
	if (this.wideMode) {
Lines 3336-3343 Link Here
3336
		lbl.branch();
3338
		lbl.branch();
3337
	}
3339
	}
3338
}
3340
}
3341
3339
public void if_icmpne(BranchLabel lbl) {
3342
public void if_icmpne(BranchLabel lbl) {
3340
	if (DEBUG) System.out.println(this.position + "\t\tif_icmpne:"+lbl); //$NON-NLS-1$
3341
	this.countLabels = 0;
3343
	this.countLabels = 0;
3342
	this.stackDepth -= 2;
3344
	this.stackDepth -= 2;
3343
	if (this.wideMode) {
3345
	if (this.wideMode) {
Lines 3351-3358 Link Here
3351
		lbl.branch();
3353
		lbl.branch();
3352
	}
3354
	}
3353
}
3355
}
3356
3354
public void ifeq(BranchLabel lbl) {
3357
public void ifeq(BranchLabel lbl) {
3355
	if (DEBUG) System.out.println(this.position + "\t\tifeq:"+lbl); //$NON-NLS-1$
3356
	this.countLabels = 0;
3358
	this.countLabels = 0;
3357
	this.stackDepth--;
3359
	this.stackDepth--;
3358
	if (this.wideMode) {
3360
	if (this.wideMode) {
Lines 3366-3373 Link Here
3366
		lbl.branch();
3368
		lbl.branch();
3367
	}
3369
	}
3368
}
3370
}
3371
3369
public void ifge(BranchLabel lbl) {
3372
public void ifge(BranchLabel lbl) {
3370
	if (DEBUG) System.out.println(this.position + "\t\tifge:"+lbl); //$NON-NLS-1$
3371
	this.countLabels = 0;
3373
	this.countLabels = 0;
3372
	this.stackDepth--;
3374
	this.stackDepth--;
3373
	if (this.wideMode) {
3375
	if (this.wideMode) {
Lines 3381-3388 Link Here
3381
		lbl.branch();
3383
		lbl.branch();
3382
	}
3384
	}
3383
}
3385
}
3386
3384
public void ifgt(BranchLabel lbl) {
3387
public void ifgt(BranchLabel lbl) {
3385
	if (DEBUG) System.out.println(this.position + "\t\tifgt:"+lbl); //$NON-NLS-1$
3386
	this.countLabels = 0;
3388
	this.countLabels = 0;
3387
	this.stackDepth--;
3389
	this.stackDepth--;
3388
	if (this.wideMode) {
3390
	if (this.wideMode) {
Lines 3396-3403 Link Here
3396
		lbl.branch();
3398
		lbl.branch();
3397
	}
3399
	}
3398
}
3400
}
3401
3399
public void ifle(BranchLabel lbl) {
3402
public void ifle(BranchLabel lbl) {
3400
	if (DEBUG) System.out.println(this.position + "\t\tifle:"+lbl); //$NON-NLS-1$
3401
	this.countLabels = 0;
3403
	this.countLabels = 0;
3402
	this.stackDepth--;
3404
	this.stackDepth--;
3403
	if (this.wideMode) {
3405
	if (this.wideMode) {
Lines 3411-3418 Link Here
3411
		lbl.branch();
3413
		lbl.branch();
3412
	}
3414
	}
3413
}
3415
}
3416
3414
public void iflt(BranchLabel lbl) {
3417
public void iflt(BranchLabel lbl) {
3415
	if (DEBUG) System.out.println(this.position + "\t\tiflt:"+lbl); //$NON-NLS-1$
3416
	this.countLabels = 0;
3418
	this.countLabels = 0;
3417
	this.stackDepth--;
3419
	this.stackDepth--;
3418
	if (this.wideMode) {
3420
	if (this.wideMode) {
Lines 3426-3433 Link Here
3426
		lbl.branch();
3428
		lbl.branch();
3427
	}
3429
	}
3428
}
3430
}
3431
3429
public void ifne(BranchLabel lbl) {
3432
public void ifne(BranchLabel lbl) {
3430
	if (DEBUG) System.out.println(this.position + "\t\tifne:"+lbl); //$NON-NLS-1$
3431
	this.countLabels = 0;
3433
	this.countLabels = 0;
3432
	this.stackDepth--;
3434
	this.stackDepth--;
3433
	if (this.wideMode) {
3435
	if (this.wideMode) {
Lines 3441-3448 Link Here
3441
		lbl.branch();
3443
		lbl.branch();
3442
	}
3444
	}
3443
}
3445
}
3446
3444
public void ifnonnull(BranchLabel lbl) {
3447
public void ifnonnull(BranchLabel lbl) {
3445
	if (DEBUG) System.out.println(this.position + "\t\tifnonnull:"+lbl); //$NON-NLS-1$
3446
	this.countLabels = 0;
3448
	this.countLabels = 0;
3447
	this.stackDepth--;
3449
	this.stackDepth--;
3448
	if (this.wideMode) {
3450
	if (this.wideMode) {
Lines 3456-3463 Link Here
3456
		lbl.branch();
3458
		lbl.branch();
3457
	}
3459
	}
3458
}
3460
}
3461
3459
public void ifnull(BranchLabel lbl) {
3462
public void ifnull(BranchLabel lbl) {
3460
	if (DEBUG) System.out.println(this.position + "\t\tifnull:"+lbl); //$NON-NLS-1$
3461
	this.countLabels = 0;
3463
	this.countLabels = 0;
3462
	this.stackDepth--;
3464
	this.stackDepth--;
3463
	if (this.wideMode) {
3465
	if (this.wideMode) {
Lines 3471-3478 Link Here
3471
		lbl.branch();
3473
		lbl.branch();
3472
	}
3474
	}
3473
}
3475
}
3476
3474
final public void iinc(int index, int value) {
3477
final public void iinc(int index, int value) {
3475
	if (DEBUG) System.out.println(this.position + "\t\tiinc:"+index+","+value); //$NON-NLS-1$ //$NON-NLS-2$
3476
	this.countLabels = 0;
3478
	this.countLabels = 0;
3477
	if ((index > 255) || (value < -128 || value > 127)) { // have to widen
3479
	if ((index > 255) || (value < -128 || value > 127)) { // have to widen
3478
		if (this.classFileOffset + 3 >= this.bCodeStream.length) {
3480
		if (this.classFileOffset + 3 >= this.bCodeStream.length) {
Lines 3493-3500 Link Here
3493
		this.bCodeStream[this.classFileOffset++] = (byte) value;
3495
		this.bCodeStream[this.classFileOffset++] = (byte) value;
3494
	}
3496
	}
3495
}
3497
}
3498
3496
public void iload(int iArg) {
3499
public void iload(int iArg) {
3497
	if (DEBUG) System.out.println(this.position + "\t\tiload:"+iArg); //$NON-NLS-1$
3498
	this.countLabels = 0;
3500
	this.countLabels = 0;
3499
	this.stackDepth++;
3501
	this.stackDepth++;
3500
	if (this.maxLocals <= iArg) {
3502
	if (this.maxLocals <= iArg) {
Lines 3519-3526 Link Here
3519
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
3521
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
3520
	}
3522
	}
3521
}
3523
}
3524
3522
public void iload_0() {
3525
public void iload_0() {
3523
	if (DEBUG) System.out.println(this.position + "\t\tiload_0"); //$NON-NLS-1$
3524
	this.countLabels = 0;
3526
	this.countLabels = 0;
3525
	this.stackDepth++;
3527
	this.stackDepth++;
3526
	if (this.maxLocals <= 0) {
3528
	if (this.maxLocals <= 0) {
Lines 3534-3541 Link Here
3534
	this.position++;
3536
	this.position++;
3535
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_0;
3537
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_0;
3536
}
3538
}
3539
3537
public void iload_1() {
3540
public void iload_1() {
3538
	if (DEBUG) System.out.println(this.position + "\t\tiload_1"); //$NON-NLS-1$
3539
	this.countLabels = 0;
3541
	this.countLabels = 0;
3540
	this.stackDepth++;
3542
	this.stackDepth++;
3541
	if (this.maxLocals <= 1) {
3543
	if (this.maxLocals <= 1) {
Lines 3549-3556 Link Here
3549
	this.position++;
3551
	this.position++;
3550
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_1;
3552
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_1;
3551
}
3553
}
3554
3552
public void iload_2() {
3555
public void iload_2() {
3553
	if (DEBUG) System.out.println(this.position + "\t\tiload_2"); //$NON-NLS-1$
3554
	this.countLabels = 0;
3556
	this.countLabels = 0;
3555
	this.stackDepth++;
3557
	this.stackDepth++;
3556
	if (this.maxLocals <= 2) {
3558
	if (this.maxLocals <= 2) {
Lines 3564-3571 Link Here
3564
	this.position++;
3566
	this.position++;
3565
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_2;
3567
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_2;
3566
}
3568
}
3569
3567
public void iload_3() {
3570
public void iload_3() {
3568
	if (DEBUG) System.out.println(this.position + "\t\tiload_3"); //$NON-NLS-1$
3569
	this.countLabels = 0;
3571
	this.countLabels = 0;
3570
	this.stackDepth++;
3572
	this.stackDepth++;
3571
	if (this.maxLocals <= 3) {
3573
	if (this.maxLocals <= 3) {
Lines 3579-3586 Link Here
3579
	this.position++;
3581
	this.position++;
3580
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_3;
3582
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iload_3;
3581
}
3583
}
3584
3582
public void imul() {
3585
public void imul() {
3583
	if (DEBUG) System.out.println(this.position + "\t\timul"); //$NON-NLS-1$
3584
	this.countLabels = 0;
3586
	this.countLabels = 0;
3585
	this.stackDepth--;
3587
	this.stackDepth--;
3586
	if (this.classFileOffset >= this.bCodeStream.length) {
3588
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 3589-3594 Link Here
3589
	this.position++;
3591
	this.position++;
3590
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_imul;
3592
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_imul;
3591
}
3593
}
3594
3592
public int indexOfSameLineEntrySincePC(int pc, int line) {
3595
public int indexOfSameLineEntrySincePC(int pc, int line) {
3593
	for (int index = pc, max = this.pcToSourceMapSize; index < max; index+=2) {
3596
	for (int index = pc, max = this.pcToSourceMapSize; index < max; index+=2) {
3594
		if (this.pcToSourceMap[index+1] == line)
3597
		if (this.pcToSourceMap[index+1] == line)
Lines 3596-3603 Link Here
3596
	}
3599
	}
3597
	return -1;
3600
	return -1;
3598
}
3601
}
3602
3599
public void ineg() {
3603
public void ineg() {
3600
	if (DEBUG) System.out.println(this.position + "\t\tineg"); //$NON-NLS-1$
3601
	this.countLabels = 0;
3604
	this.countLabels = 0;
3602
	if (this.classFileOffset >= this.bCodeStream.length) {
3605
	if (this.classFileOffset >= this.bCodeStream.length) {
3603
		resizeByteArray();
3606
		resizeByteArray();
Lines 3605-3634 Link Here
3605
	this.position++;
3608
	this.position++;
3606
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ineg;
3609
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ineg;
3607
}
3610
}
3608
/*
3611
3609
 * Some placed labels might be branching to a goto bytecode which we can optimize better.
3610
 */
3611
public boolean inlineForwardReferencesFromLabelsTargeting(BranchLabel targetLabel, int gotoLocation) {
3612
	if (targetLabel.delegate != null) return false; // already inlined
3613
	int chaining = L_UNKNOWN;
3614
	for (int i = this.countLabels - 1; i >= 0; i--) {
3615
		BranchLabel currentLabel = this.labels[i];
3616
		if (currentLabel.position != gotoLocation) break;
3617
		if (currentLabel == targetLabel) {
3618
			chaining |= L_CANNOT_OPTIMIZE; // recursive
3619
			continue;
3620
		}
3621
		if (currentLabel.isStandardLabel()) {
3622
			if (currentLabel.delegate != null) continue; // ignore since already inlined
3623
			targetLabel.becomeDelegateFor(currentLabel);
3624
			chaining |= L_OPTIMIZABLE; // optimizable, providing no vetoing
3625
			continue;
3626
		}
3627
		// case label
3628
		chaining |= L_CANNOT_OPTIMIZE;
3629
	}
3630
	return (chaining & (L_OPTIMIZABLE|L_CANNOT_OPTIMIZE)) == L_OPTIMIZABLE; // check was some standards, and no case/recursive
3631
}
3632
public void init(ClassFile targetClassFile) {
3612
public void init(ClassFile targetClassFile) {
3633
	this.classFile = targetClassFile;
3613
	this.classFile = targetClassFile;
3634
	this.constantPool = targetClassFile.constantPool;
3614
	this.constantPool = targetClassFile.constantPool;
Lines 3671-3686 Link Here
3671
	this.maxLocals = 0;
3651
	this.maxLocals = 0;
3672
	this.position = 0;
3652
	this.position = 0;
3673
}
3653
}
3654
3674
/**
3655
/**
3675
 * @param methodBinding the given method binding to initialize the max locals
3656
 * @param methodBinding the given method binding to initialize the max locals
3676
 */
3657
 */
3677
public void initializeMaxLocals(MethodBinding methodBinding) {
3658
public void initializeMaxLocals(MethodBinding methodBinding) {
3678
3679
	if (methodBinding == null) {
3659
	if (methodBinding == null) {
3680
		this.maxLocals = 0;
3660
		this.maxLocals = 0;
3681
		return;
3661
		return;
3682
	}
3662
	}
3683
3684
	this.maxLocals = methodBinding.isStatic() ? 0 : 1;
3663
	this.maxLocals = methodBinding.isStatic() ? 0 : 1;
3685
3664
3686
	// take into account enum constructor synthetic name+ordinal
3665
	// take into account enum constructor synthetic name+ordinal
Lines 3721-3793 Link Here
3721
		}
3700
		}
3722
	}
3701
	}
3723
}
3702
}
3703
3724
/**
3704
/**
3725
 * We didn't call it instanceof because there is a conflit with the
3705
 * Some placed labels might be branching to a goto bytecode which we can optimize better.
3726
 * instanceof keyword
3727
 */
3706
 */
3728
public void instance_of(TypeBinding typeBinding) {
3707
public boolean inlineForwardReferencesFromLabelsTargeting(BranchLabel targetLabel, int gotoLocation) {
3729
	if (DEBUG) System.out.println(this.position + "\t\tinstance_of:"+typeBinding); //$NON-NLS-1$
3708
	if (targetLabel.delegate != null) return false; // already inlined
3730
	this.countLabels = 0;
3709
	int chaining = L_UNKNOWN;
3731
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
3710
	for (int i = this.countLabels - 1; i >= 0; i--) {
3732
		resizeByteArray();
3711
		BranchLabel currentLabel = this.labels[i];
3733
	}
3712
		if (currentLabel.position != gotoLocation) break;
3734
	this.position++;
3713
		if (currentLabel == targetLabel) {
3735
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_instanceof;
3714
			chaining |= L_CANNOT_OPTIMIZE; // recursive
3736
	writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
3715
			continue;
3716
		}
3717
		if (currentLabel.isStandardLabel()) {
3718
			if (currentLabel.delegate != null) continue; // ignore since already inlined
3719
			targetLabel.becomeDelegateFor(currentLabel);
3720
			chaining |= L_OPTIMIZABLE; // optimizable, providing no vetoing
3721
			continue;
3722
		}
3723
		// case label
3724
		chaining |= L_CANNOT_OPTIMIZE;
3725
	}
3726
	return (chaining & (L_OPTIMIZABLE|L_CANNOT_OPTIMIZE)) == L_OPTIMIZABLE; // check was some standards, and no case/recursive
3737
}
3727
}
3738
protected void invoke(int opcode, int argsSize, int returnTypeSize, char[] declaringClass, char[] selector, char[] signature) {
3728
3729
/**
3730
 * We didn't call it instanceof because there is a conflit with the
3731
 * instanceof keyword
3732
 */
3733
public void instance_of(TypeBinding typeBinding) {
3739
	this.countLabels = 0;
3734
	this.countLabels = 0;
3740
	int argCount = argsSize;
3735
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
3741
	switch(opcode) {
3736
		resizeByteArray();
3742
		case Opcodes.OPC_invokeinterface :
3743
			if (this.classFileOffset + 4 >= this.bCodeStream.length) {
3744
				resizeByteArray();
3745
			}
3746
			this.position +=3;
3747
			this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokeinterface;
3748
			writeUnsignedShort(this.constantPool.literalIndexForMethod(declaringClass, selector, signature, true));
3749
			argCount++;
3750
			this.bCodeStream[this.classFileOffset++] = (byte) argCount;
3751
			this.bCodeStream[this.classFileOffset++] = 0;
3752
			break;
3753
		case Opcodes.OPC_invokevirtual :
3754
		case Opcodes.OPC_invokespecial :
3755
			if (this.classFileOffset + 2 >= this.bCodeStream.length) {
3756
				resizeByteArray();
3757
			}
3758
			this.position++;
3759
			this.bCodeStream[this.classFileOffset++] = (byte) opcode;
3760
			writeUnsignedShort(this.constantPool.literalIndexForMethod(declaringClass, selector, signature, false));
3761
			argCount++;
3762
			break;
3763
		case Opcodes.OPC_invokestatic :
3764
			if (this.classFileOffset + 2 >= this.bCodeStream.length) {
3765
				resizeByteArray();
3766
			}
3767
			this.position++;
3768
			this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokestatic;
3769
			writeUnsignedShort(this.constantPool.literalIndexForMethod(declaringClass, selector, signature, false));
3770
	}
3737
	}
3771
	this.stackDepth += returnTypeSize - argCount;
3738
	this.position++;
3739
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_instanceof;
3740
	writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
3741
}
3742
3743
public void invoke(byte opcode, MethodBinding methodBinding, TypeBinding declaringClass) {
3744
	if (declaringClass == null) declaringClass = methodBinding.declaringClass;
3745
    if (declaringClass.isNestedType()) {
3746
        this.classFile.recordInnerClasses(declaringClass);
3747
    }
3748
    // compute receiverAndArgsSize
3749
    int receiverAndArgsSize;
3750
    switch(opcode) {
3751
    	case Opcodes.OPC_invokestatic :
3752
    		receiverAndArgsSize = 0; // no receiver
3753
    		break;
3754
    	case Opcodes.OPC_invokeinterface :
3755
    	case Opcodes.OPC_invokevirtual :
3756
    		receiverAndArgsSize = 1; // receiver
3757
    		break;
3758
    	case Opcodes.OPC_invokespecial :
3759
    		receiverAndArgsSize = 1; // receiver
3760
    		if (methodBinding.isConstructor()) {
3761
    			if (declaringClass.isNestedType()) {
3762
        			ReferenceBinding nestedType = (ReferenceBinding) declaringClass;
3763
    				// enclosing instances
3764
    				TypeBinding[] syntheticArgumentTypes = nestedType.syntheticEnclosingInstanceTypes();
3765
    				if (syntheticArgumentTypes != null) {
3766
    					for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
3767
    						switch (syntheticArgumentTypes[i].id)  {
3768
    							case TypeIds.T_double :
3769
    							case TypeIds.T_long :
3770
	    							receiverAndArgsSize += 2;
3771
									break;
3772
    							default: 
3773
	    							receiverAndArgsSize++;
3774
    								break;
3775
    						}
3776
    					}
3777
    				}
3778
    				// outer local variables
3779
    				SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
3780
    				if (syntheticArguments != null) {
3781
    					for (int i = 0, max = syntheticArguments.length; i < max; i++) {
3782
    						switch (syntheticArguments[i].id)  {
3783
    							case TypeIds.T_double :
3784
    							case TypeIds.T_long :
3785
	    							receiverAndArgsSize += 2;
3786
									break;
3787
    							default: 
3788
	    							receiverAndArgsSize++;
3789
    								break;
3790
    						}    						
3791
    					}
3792
    				}
3793
    			}
3794
    			if (declaringClass.isEnum()) {
3795
    				// adding String (name) and int (ordinal)
3796
    				receiverAndArgsSize += 2;
3797
    			}
3798
    		}    		
3799
    		break;
3800
    	default :
3801
    		return; // should not occur
3802
    		
3803
    }
3804
	for (int i = methodBinding.parameters.length - 1; i >= 0; i--) {
3805
		switch (methodBinding.parameters[i].id) {
3806
			case TypeIds.T_double :
3807
			case TypeIds.T_long :
3808
				receiverAndArgsSize += 2;
3809
				break;
3810
			default :
3811
				receiverAndArgsSize ++;
3812
				break;
3813
		}
3814
	}
3815
	// compute return type size
3816
	int returnTypeSize;
3817
	switch (methodBinding.returnType.id) {
3818
		case TypeIds.T_double :
3819
		case TypeIds.T_long :
3820
			returnTypeSize = 2;
3821
			break;
3822
		case TypeIds.T_void :
3823
			returnTypeSize = 0;
3824
			break;
3825
		default :
3826
			returnTypeSize = 1;
3827
			break;
3828
	}
3829
	invoke(
3830
			opcode, 
3831
			receiverAndArgsSize, 
3832
			returnTypeSize, 
3833
			declaringClass.constantPoolName(), 
3834
			methodBinding.selector, 
3835
			methodBinding.signature(this.classFile));
3836
}
3837
3838
protected void invoke(byte opcode, int receiverAndArgsSize, int returnTypeSize, char[] declaringClass, char[] selector, char[] signature) {
3839
	this.countLabels = 0;
3840
	if (opcode == Opcodes.OPC_invokeinterface) {
3841
		// invokeinterface
3842
		if (this.classFileOffset + 4 >= this.bCodeStream.length) {
3843
			resizeByteArray();
3844
		}
3845
		this.position +=3;
3846
		this.bCodeStream[this.classFileOffset++] = opcode;
3847
		writeUnsignedShort(this.constantPool.literalIndexForMethod(declaringClass, selector, signature, true));
3848
		this.bCodeStream[this.classFileOffset++] = (byte) receiverAndArgsSize;
3849
		this.bCodeStream[this.classFileOffset++] = 0;
3850
	} else {
3851
		// invokespecial
3852
		// invokestatic
3853
		// invokevirtual
3854
		if (this.classFileOffset + 2 >= this.bCodeStream.length) {
3855
			resizeByteArray();
3856
		}
3857
		this.position++;
3858
		this.bCodeStream[this.classFileOffset++] = opcode;
3859
		writeUnsignedShort(this.constantPool.literalIndexForMethod(declaringClass, selector, signature, false));
3860
	}
3861
	this.stackDepth += returnTypeSize - receiverAndArgsSize;
3772
	if (this.stackDepth > this.stackMax) {
3862
	if (this.stackDepth > this.stackMax) {
3773
		this.stackMax = this.stackDepth;
3863
		this.stackMax = this.stackDepth;
3774
	}
3864
	}
3775
}
3865
}
3866
3776
protected void invokeAccessibleObjectSetAccessible() {
3867
protected void invokeAccessibleObjectSetAccessible() {
3777
	// invokevirtual: java.lang.reflect.AccessibleObject.setAccessible(Z)V;
3868
	// invokevirtual: java.lang.reflect.AccessibleObject.setAccessible(Z)V;
3778
	invoke(
3869
	invoke(
3779
			Opcodes.OPC_invokevirtual,
3870
			Opcodes.OPC_invokevirtual,
3780
			1, // argCount
3871
			2, // receiverAndArgsSize
3781
			0, // return type size
3872
			0, // return type size
3782
			ConstantPool.JAVALANGREFLECTACCESSIBLEOBJECT_CONSTANTPOOLNAME,
3873
			ConstantPool.JAVALANGREFLECTACCESSIBLEOBJECT_CONSTANTPOOLNAME,
3783
			ConstantPool.SETACCESSIBLE_NAME,
3874
			ConstantPool.SETACCESSIBLE_NAME,
3784
			ConstantPool.SETACCESSIBLE_SIGNATURE);
3875
			ConstantPool.SETACCESSIBLE_SIGNATURE);
3785
}
3876
}
3877
3786
protected void invokeArrayNewInstance() {
3878
protected void invokeArrayNewInstance() {
3787
	// invokestatic: java.lang.reflect.Array.newInstance(Ljava.lang.Class;int[])Ljava.lang.Object;
3879
	// invokestatic: java.lang.reflect.Array.newInstance(Ljava.lang.Class;int[])Ljava.lang.Object;
3788
	invoke(
3880
	invoke(
3789
			Opcodes.OPC_invokestatic,
3881
			Opcodes.OPC_invokestatic,
3790
			2, // argCount
3882
			2, // receiverAndArgsSize
3791
			1, // return type size
3883
			1, // return type size
3792
			ConstantPool.JAVALANGREFLECTARRAY_CONSTANTPOOLNAME,
3884
			ConstantPool.JAVALANGREFLECTARRAY_CONSTANTPOOLNAME,
3793
			ConstantPool.NewInstance,
3885
			ConstantPool.NewInstance,
Lines 3795-4006 Link Here
3795
}
3887
}
3796
public void invokeClassForName() {
3888
public void invokeClassForName() {
3797
	// invokestatic: java.lang.Class.forName(Ljava.lang.String;)Ljava.lang.Class;
3889
	// invokestatic: java.lang.Class.forName(Ljava.lang.String;)Ljava.lang.Class;
3798
	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic: java.lang.Class.forName(Ljava.lang.String;)Ljava.lang.Class;"); //$NON-NLS-1$
3799
	invoke(
3890
	invoke(
3800
		Opcodes.OPC_invokestatic,
3891
		Opcodes.OPC_invokestatic,
3801
		1, // argCount
3892
		1, // receiverAndArgsSize
3802
		1, // return type size
3893
		1, // return type size
3803
		ConstantPool.JavaLangClassConstantPoolName,
3894
		ConstantPool.JavaLangClassConstantPoolName,
3804
		ConstantPool.ForName,
3895
		ConstantPool.ForName,
3805
		ConstantPool.ForNameSignature);
3896
		ConstantPool.ForNameSignature);
3806
}
3897
}
3898
3807
protected void invokeClassGetDeclaredConstructor() {
3899
protected void invokeClassGetDeclaredConstructor() {
3808
	// invokevirtual: java.lang.Class getDeclaredConstructor([Ljava.lang.Class)Ljava.lang.reflect.Constructor;
3900
	// invokevirtual: java.lang.Class getDeclaredConstructor([Ljava.lang.Class)Ljava.lang.reflect.Constructor;
3809
	invoke(
3901
	invoke(
3810
			Opcodes.OPC_invokevirtual,
3902
			Opcodes.OPC_invokevirtual,
3811
			1, // argCount
3903
			2, // receiverAndArgsSize
3812
			1, // return type size
3904
			1, // return type size
3813
			ConstantPool.JavaLangClassConstantPoolName,
3905
			ConstantPool.JavaLangClassConstantPoolName,
3814
			ConstantPool.GETDECLAREDCONSTRUCTOR_NAME,
3906
			ConstantPool.GETDECLAREDCONSTRUCTOR_NAME,
3815
			ConstantPool.GETDECLAREDCONSTRUCTOR_SIGNATURE);
3907
			ConstantPool.GETDECLAREDCONSTRUCTOR_SIGNATURE);
3816
}
3908
}
3909
3817
protected void invokeClassGetDeclaredField() {
3910
protected void invokeClassGetDeclaredField() {
3818
	// invokevirtual: java.lang.Class.getDeclaredField(Ljava.lang.String)Ljava.lang.reflect.Field;
3911
	// invokevirtual: java.lang.Class.getDeclaredField(Ljava.lang.String)Ljava.lang.reflect.Field;
3819
	invoke(
3912
	invoke(
3820
			Opcodes.OPC_invokevirtual,
3913
			Opcodes.OPC_invokevirtual,
3821
			1, // argCount
3914
			2, // receiverAndArgsSize
3822
			1, // return type size
3915
			1, // return type size
3823
			ConstantPool.JavaLangClassConstantPoolName,
3916
			ConstantPool.JavaLangClassConstantPoolName,
3824
			ConstantPool.GETDECLAREDFIELD_NAME,
3917
			ConstantPool.GETDECLAREDFIELD_NAME,
3825
			ConstantPool.GETDECLAREDFIELD_SIGNATURE);
3918
			ConstantPool.GETDECLAREDFIELD_SIGNATURE);
3826
}
3919
}
3920
3827
protected void invokeClassGetDeclaredMethod() {
3921
protected void invokeClassGetDeclaredMethod() {
3828
	// invokevirtual: java.lang.Class getDeclaredMethod(Ljava.lang.String, [Ljava.lang.Class)Ljava.lang.reflect.Method;
3922
	// invokevirtual: java.lang.Class getDeclaredMethod(Ljava.lang.String, [Ljava.lang.Class)Ljava.lang.reflect.Method;
3829
	invoke(
3923
	invoke(
3830
			Opcodes.OPC_invokevirtual,
3924
			Opcodes.OPC_invokevirtual,
3831
			2, // argCount
3925
			3, // receiverAndArgsSize
3832
			1, // return type size
3926
			1, // return type size
3833
			ConstantPool.JavaLangClassConstantPoolName,
3927
			ConstantPool.JavaLangClassConstantPoolName,
3834
			ConstantPool.GETDECLAREDMETHOD_NAME,
3928
			ConstantPool.GETDECLAREDMETHOD_NAME,
3835
			ConstantPool.GETDECLAREDMETHOD_SIGNATURE);
3929
			ConstantPool.GETDECLAREDMETHOD_SIGNATURE);
3836
}
3930
}
3931
3837
public void invokeEnumOrdinal(char[] enumTypeConstantPoolName) {
3932
public void invokeEnumOrdinal(char[] enumTypeConstantPoolName) {
3838
	// invokevirtual: <enumConstantPoolName>.ordinal()
3933
	// invokevirtual: <enumConstantPoolName>.ordinal()
3839
	if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: "+new String(enumTypeConstantPoolName)+".ordinal()"); //$NON-NLS-1$ //$NON-NLS-2$
3840
	invoke(
3934
	invoke(
3841
			Opcodes.OPC_invokevirtual,
3935
			Opcodes.OPC_invokevirtual,
3842
			0, // argCount
3936
			1, // receiverAndArgsSize
3843
			1, // return type size
3937
			1, // return type size
3844
			enumTypeConstantPoolName,
3938
			enumTypeConstantPoolName,
3845
			ConstantPool.Ordinal,
3939
			ConstantPool.Ordinal,
3846
			ConstantPool.OrdinalSignature);
3940
			ConstantPool.OrdinalSignature);
3847
}
3941
}
3848
public void invokeinterface(MethodBinding methodBinding) {
3942
3849
	if (DEBUG) System.out.println(this.position + "\t\tinvokeinterface: " + methodBinding); //$NON-NLS-1$
3943
public void invokeIterableIterator(TypeBinding iterableReceiverType) {
3850
	this.countLabels = 0;
3944
	// invokevirtual/interface: <iterableReceiverType>.iterator()
3851
	// initialized to 1 to take into account this  immediately
3945
    if (iterableReceiverType.isNestedType()) {
3852
	int argCount = 1;
3946
        this.classFile.recordInnerClasses(iterableReceiverType);
3853
	int id;
3947
    }	
3854
	if (this.classFileOffset + 4 >= this.bCodeStream.length) {
3948
	invoke(
3855
		resizeByteArray();
3949
			iterableReceiverType.isInterface() ? Opcodes.OPC_invokeinterface : Opcodes.OPC_invokevirtual,
3856
	}
3950
			1, // receiverAndArgsSize
3857
	this.position += 3;
3951
			1, // returnTypeSize
3858
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokeinterface;
3952
			iterableReceiverType.constantPoolName(), 
3859
	writeUnsignedShort(
3953
			ConstantPool.ITERATOR_NAME, 
3860
		this.constantPool.literalIndexForMethod(
3954
			ConstantPool.ITERATOR_SIGNATURE);
3861
			methodBinding.constantPoolDeclaringClass(),
3862
			methodBinding.selector,
3863
			methodBinding.signature(this.classFile),
3864
			true));
3865
	for (int i = methodBinding.parameters.length - 1; i >= 0; i--)
3866
		if (((id = methodBinding.parameters[i].id) == TypeIds.T_double) || (id == TypeIds.T_long))
3867
			argCount += 2;
3868
		else
3869
			argCount += 1;
3870
	this.bCodeStream[this.classFileOffset++] = (byte) argCount;
3871
	// Generate a  0 into the byte array. Like the array is already fill with 0, we just need to increment
3872
	// the number of bytes.
3873
	this.bCodeStream[this.classFileOffset++] = 0;
3874
	if (((id = methodBinding.returnType.id) == TypeIds.T_double) || (id == TypeIds.T_long)) {
3875
		this.stackDepth += (2 - argCount);
3876
	} else {
3877
		if (id == TypeIds.T_void) {
3878
			this.stackDepth -= argCount;
3879
		} else {
3880
			this.stackDepth += (1 - argCount);
3881
		}
3882
	}
3883
	if (this.stackDepth > this.stackMax) {
3884
		this.stackMax = this.stackDepth;
3885
	}
3886
}
3955
}
3956
3887
public void invokeJavaLangAssertionErrorConstructor(int typeBindingID) {
3957
public void invokeJavaLangAssertionErrorConstructor(int typeBindingID) {
3888
	// invokespecial: java.lang.AssertionError.<init>(typeBindingID)V
3958
	// invokespecial: java.lang.AssertionError.<init>(typeBindingID)V
3889
	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial: java.lang.AssertionError.<init>(typeBindingID)V"); //$NON-NLS-1$
3959
	int receiverAndArgsSize;
3890
	int argCount = 1;
3960
	char[] signature;
3891
	char[] signature = null;
3892
	switch (typeBindingID) {
3961
	switch (typeBindingID) {
3893
		case TypeIds.T_int :
3962
		case TypeIds.T_int :
3894
		case TypeIds.T_byte :
3963
		case TypeIds.T_byte :
3895
		case TypeIds.T_short :
3964
		case TypeIds.T_short :
3896
			signature = ConstantPool.IntConstrSignature;
3965
			signature = ConstantPool.IntConstrSignature;
3966
			receiverAndArgsSize = 2;
3897
			break;
3967
			break;
3898
		case TypeIds.T_long :
3968
		case TypeIds.T_long :
3899
			signature = ConstantPool.LongConstrSignature;
3969
			signature = ConstantPool.LongConstrSignature;
3900
			argCount = 2;
3970
			receiverAndArgsSize = 3;
3901
			break;
3971
			break;
3902
		case TypeIds.T_float :
3972
		case TypeIds.T_float :
3903
			signature = ConstantPool.FloatConstrSignature;
3973
			signature = ConstantPool.FloatConstrSignature;
3974
			receiverAndArgsSize = 2;
3904
			break;
3975
			break;
3905
		case TypeIds.T_double :
3976
		case TypeIds.T_double :
3906
			signature = ConstantPool.DoubleConstrSignature;
3977
			signature = ConstantPool.DoubleConstrSignature;
3907
			argCount = 2;
3978
			receiverAndArgsSize = 3;
3908
			break;
3979
			break;
3909
		case TypeIds.T_char :
3980
		case TypeIds.T_char :
3910
			signature = ConstantPool.CharConstrSignature;
3981
			signature = ConstantPool.CharConstrSignature;
3982
			receiverAndArgsSize = 2;
3911
			break;
3983
			break;
3912
		case TypeIds.T_boolean :
3984
		case TypeIds.T_boolean :
3913
			signature = ConstantPool.BooleanConstrSignature;
3985
			signature = ConstantPool.BooleanConstrSignature;
3986
			receiverAndArgsSize = 2;
3914
			break;
3987
			break;
3915
		case TypeIds.T_JavaLangObject :
3988
		case TypeIds.T_JavaLangObject :
3916
		case TypeIds.T_JavaLangString :
3989
		case TypeIds.T_JavaLangString :
3917
		case TypeIds.T_null :
3990
		case TypeIds.T_null :
3918
			signature = ConstantPool.ObjectConstrSignature;
3991
			signature = ConstantPool.ObjectConstrSignature;
3992
			receiverAndArgsSize = 2;
3919
			break;
3993
			break;
3994
		default:
3995
			return; // should not occur
3920
	}
3996
	}
3921
	invoke(
3997
	invoke(
3922
			Opcodes.OPC_invokespecial,
3998
			Opcodes.OPC_invokespecial,
3923
			argCount, // argCount
3999
			receiverAndArgsSize,
3924
			0, // return type size
4000
			0, // return type size
3925
			ConstantPool.JavaLangAssertionErrorConstantPoolName,
4001
			ConstantPool.JavaLangAssertionErrorConstantPoolName,
3926
			ConstantPool.Init,
4002
			ConstantPool.Init,
3927
			signature);
4003
			signature);
3928
}
4004
}
4005
3929
public void invokeJavaLangAssertionErrorDefaultConstructor() {
4006
public void invokeJavaLangAssertionErrorDefaultConstructor() {
3930
	// invokespecial: java.lang.AssertionError.<init>()V
4007
	// invokespecial: java.lang.AssertionError.<init>()V
3931
	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial: java.lang.AssertionError.<init>()V"); //$NON-NLS-1$
3932
	invoke(
4008
	invoke(
3933
			Opcodes.OPC_invokespecial,
4009
			Opcodes.OPC_invokespecial,
3934
			0, // argCount
4010
			1, // receiverAndArgsSize
3935
			0, // return type size
4011
			0, // return type size
3936
			ConstantPool.JavaLangAssertionErrorConstantPoolName,
4012
			ConstantPool.JavaLangAssertionErrorConstantPoolName,
3937
			ConstantPool.Init,
4013
			ConstantPool.Init,
3938
			ConstantPool.DefaultConstructorSignature);
4014
			ConstantPool.DefaultConstructorSignature);
3939
}
4015
}
4016
3940
public void invokeJavaLangClassDesiredAssertionStatus() {
4017
public void invokeJavaLangClassDesiredAssertionStatus() {
3941
	// invokevirtual: java.lang.Class.desiredAssertionStatus()Z;
4018
	// invokevirtual: java.lang.Class.desiredAssertionStatus()Z;
3942
	if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: java.lang.Class.desiredAssertionStatus()Z;"); //$NON-NLS-1$
3943
	invoke(
4019
	invoke(
3944
			Opcodes.OPC_invokevirtual,
4020
			Opcodes.OPC_invokevirtual,
3945
			0, // argCount
4021
			1, // receiverAndArgsSize
3946
			1, // return type size
4022
			1, // return type size
3947
			ConstantPool.JavaLangClassConstantPoolName,
4023
			ConstantPool.JavaLangClassConstantPoolName,
3948
			ConstantPool.DesiredAssertionStatus,
4024
			ConstantPool.DesiredAssertionStatus,
3949
			ConstantPool.DesiredAssertionStatusSignature);
4025
			ConstantPool.DesiredAssertionStatusSignature);
3950
}
4026
}
4027
3951
public void invokeJavaLangEnumvalueOf(ReferenceBinding binding) {
4028
public void invokeJavaLangEnumvalueOf(ReferenceBinding binding) {
3952
	// invokestatic: java.lang.Enum.valueOf(Class,String)
4029
	// invokestatic: java.lang.Enum.valueOf(Class,String)
3953
	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic: java.lang.Enum.valueOf(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;"); //$NON-NLS-1$
3954
	invoke(
4030
	invoke(
3955
			Opcodes.OPC_invokestatic,
4031
			Opcodes.OPC_invokestatic,
3956
			2, // argCount
4032
			2, // receiverAndArgsSize
3957
			1, // return type size
4033
			1, // return type size
3958
			ConstantPool.JavaLangEnumConstantPoolName,
4034
			ConstantPool.JavaLangEnumConstantPoolName,
3959
			ConstantPool.ValueOf,
4035
			ConstantPool.ValueOf,
3960
			ConstantPool.ValueOfStringClassSignature);
4036
			ConstantPool.ValueOfStringClassSignature);
3961
}
4037
}
4038
3962
public void invokeJavaLangEnumValues(TypeBinding enumBinding, ArrayBinding arrayBinding) {
4039
public void invokeJavaLangEnumValues(TypeBinding enumBinding, ArrayBinding arrayBinding) {
3963
	char[] signature = "()".toCharArray(); //$NON-NLS-1$
4040
	char[] signature = "()".toCharArray(); //$NON-NLS-1$
3964
	signature = CharOperation.concat(signature, arrayBinding.constantPoolName());
4041
	signature = CharOperation.concat(signature, arrayBinding.constantPoolName());
3965
	invoke(Opcodes.OPC_invokestatic, 0, 1, enumBinding.constantPoolName(), TypeConstants.VALUES, signature);
4042
	invoke(
4043
			Opcodes.OPC_invokestatic, 
4044
			0,  // receiverAndArgsSize
4045
			1,  // return type size
4046
			enumBinding.constantPoolName(), 
4047
			TypeConstants.VALUES, 
4048
			signature);
3966
}
4049
}
4050
3967
public void invokeJavaLangErrorConstructor() {
4051
public void invokeJavaLangErrorConstructor() {
3968
	// invokespecial: java.lang.Error<init>(Ljava.lang.String;)V
4052
	// invokespecial: java.lang.Error<init>(Ljava.lang.String;)V
3969
	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial: java.lang.Error<init>(Ljava.lang.String;)V"); //$NON-NLS-1$
3970
	invoke(
4053
	invoke(
3971
			Opcodes.OPC_invokespecial,
4054
			Opcodes.OPC_invokespecial,
3972
			1, // argCount
4055
			2, // receiverAndArgsSize
3973
			0, // return type size
4056
			0, // return type size
3974
			ConstantPool.JavaLangErrorConstantPoolName,
4057
			ConstantPool.JavaLangErrorConstantPoolName,
3975
			ConstantPool.Init,
4058
			ConstantPool.Init,
3976
			ConstantPool.StringConstructorSignature);
4059
			ConstantPool.StringConstructorSignature);
3977
}
4060
}
4061
3978
public void invokeJavaLangReflectConstructorNewInstance() {
4062
public void invokeJavaLangReflectConstructorNewInstance() {
3979
	// invokevirtual: java.lang.reflect.Constructor.newInstance([Ljava.lang.Object;)Ljava.lang.Object;
4063
	// invokevirtual: java.lang.reflect.Constructor.newInstance([Ljava.lang.Object;)Ljava.lang.Object;
3980
	invoke(
4064
	invoke(
3981
			Opcodes.OPC_invokevirtual,
4065
			Opcodes.OPC_invokevirtual,
3982
			1, // argCount
4066
			2, // receiverAndArgsSize
3983
			1, // return type size
4067
			1, // return type size
3984
			ConstantPool.JavaLangReflectConstructorConstantPoolName,
4068
			ConstantPool.JavaLangReflectConstructorConstantPoolName,
3985
			ConstantPool.NewInstance,
4069
			ConstantPool.NewInstance,
3986
			ConstantPool.JavaLangReflectConstructorNewInstanceSignature);
4070
			ConstantPool.JavaLangReflectConstructorNewInstanceSignature);
3987
}
4071
}
4072
3988
protected void invokeJavaLangReflectFieldGetter(int typeID) {
4073
protected void invokeJavaLangReflectFieldGetter(int typeID) {
3989
	int returnTypeSize = 1;
4074
	char[] selector;
3990
	char[] signature = null;
4075
	char[] signature;
3991
	char[] selector = null;
4076
	int returnTypeSize;
3992
	switch (typeID) {
4077
	switch (typeID) {
3993
		case TypeIds.T_int :
4078
		case TypeIds.T_int :
3994
			selector = ConstantPool.GET_INT_METHOD_NAME;
4079
			selector = ConstantPool.GET_INT_METHOD_NAME;
3995
			signature = ConstantPool.GET_INT_METHOD_SIGNATURE;
4080
			signature = ConstantPool.GET_INT_METHOD_SIGNATURE;
4081
			returnTypeSize = 1;
3996
			break;
4082
			break;
3997
		case TypeIds.T_byte :
4083
		case TypeIds.T_byte :
3998
			selector = ConstantPool.GET_BYTE_METHOD_NAME;
4084
			selector = ConstantPool.GET_BYTE_METHOD_NAME;
3999
			signature = ConstantPool.GET_BYTE_METHOD_SIGNATURE;
4085
			signature = ConstantPool.GET_BYTE_METHOD_SIGNATURE;
4086
			returnTypeSize = 1;
4000
			break;
4087
			break;
4001
		case TypeIds.T_short :
4088
		case TypeIds.T_short :
4002
			selector = ConstantPool.GET_SHORT_METHOD_NAME;
4089
			selector = ConstantPool.GET_SHORT_METHOD_NAME;
4003
			signature = ConstantPool.GET_SHORT_METHOD_SIGNATURE;
4090
			signature = ConstantPool.GET_SHORT_METHOD_SIGNATURE;
4091
			returnTypeSize = 1;
4004
			break;
4092
			break;
4005
		case TypeIds.T_long :
4093
		case TypeIds.T_long :
4006
			selector = ConstantPool.GET_LONG_METHOD_NAME;
4094
			selector = ConstantPool.GET_LONG_METHOD_NAME;
Lines 4010-4015 Link Here
4010
		case TypeIds.T_float :
4098
		case TypeIds.T_float :
4011
			selector = ConstantPool.GET_FLOAT_METHOD_NAME;
4099
			selector = ConstantPool.GET_FLOAT_METHOD_NAME;
4012
			signature = ConstantPool.GET_FLOAT_METHOD_SIGNATURE;
4100
			signature = ConstantPool.GET_FLOAT_METHOD_SIGNATURE;
4101
			returnTypeSize = 1;
4013
			break;
4102
			break;
4014
		case TypeIds.T_double :
4103
		case TypeIds.T_double :
4015
			selector = ConstantPool.GET_DOUBLE_METHOD_NAME;
4104
			selector = ConstantPool.GET_DOUBLE_METHOD_NAME;
Lines 4019-4258 Link Here
4019
		case TypeIds.T_char :
4108
		case TypeIds.T_char :
4020
			selector = ConstantPool.GET_CHAR_METHOD_NAME;
4109
			selector = ConstantPool.GET_CHAR_METHOD_NAME;
4021
			signature = ConstantPool.GET_CHAR_METHOD_SIGNATURE;
4110
			signature = ConstantPool.GET_CHAR_METHOD_SIGNATURE;
4111
			returnTypeSize = 1;
4022
			break;
4112
			break;
4023
		case TypeIds.T_boolean :
4113
		case TypeIds.T_boolean :
4024
			selector = ConstantPool.GET_BOOLEAN_METHOD_NAME;
4114
			selector = ConstantPool.GET_BOOLEAN_METHOD_NAME;
4025
			signature = ConstantPool.GET_BOOLEAN_METHOD_SIGNATURE;
4115
			signature = ConstantPool.GET_BOOLEAN_METHOD_SIGNATURE;
4116
			returnTypeSize = 1;
4026
			break;
4117
			break;
4027
		default :
4118
		default :
4028
			selector = ConstantPool.GET_OBJECT_METHOD_NAME;
4119
			selector = ConstantPool.GET_OBJECT_METHOD_NAME;
4029
			signature = ConstantPool.GET_OBJECT_METHOD_SIGNATURE;
4120
			signature = ConstantPool.GET_OBJECT_METHOD_SIGNATURE;
4121
			returnTypeSize = 1;
4030
			break;
4122
			break;
4031
	}
4123
	}
4032
	invoke(
4124
	invoke(
4033
			Opcodes.OPC_invokevirtual,
4125
			Opcodes.OPC_invokevirtual,
4034
			1, // argCount
4126
			2, // receiverAndArgsSize
4035
			returnTypeSize, // return type size
4127
			returnTypeSize, // return type size
4036
			ConstantPool.JAVALANGREFLECTFIELD_CONSTANTPOOLNAME,
4128
			ConstantPool.JAVALANGREFLECTFIELD_CONSTANTPOOLNAME,
4037
			selector,
4129
			selector,
4038
			signature);
4130
			signature);
4039
}
4131
}
4132
4040
protected void invokeJavaLangReflectFieldSetter(int typeID) {
4133
protected void invokeJavaLangReflectFieldSetter(int typeID) {
4041
	int argCount = 2;
4134
	char[] selector;
4042
	char[] signature = null;
4135
	char[] signature;
4043
	char[] selector = null;
4136
	int receiverAndArgsSize;
4044
	switch (typeID) {
4137
	switch (typeID) {
4045
		case TypeIds.T_int :
4138
		case TypeIds.T_int :
4046
			selector = ConstantPool.SET_INT_METHOD_NAME;
4139
			selector = ConstantPool.SET_INT_METHOD_NAME;
4047
			signature = ConstantPool.SET_INT_METHOD_SIGNATURE;
4140
			signature = ConstantPool.SET_INT_METHOD_SIGNATURE;
4141
			receiverAndArgsSize = 3;
4048
			break;
4142
			break;
4049
		case TypeIds.T_byte :
4143
		case TypeIds.T_byte :
4050
			selector = ConstantPool.SET_BYTE_METHOD_NAME;
4144
			selector = ConstantPool.SET_BYTE_METHOD_NAME;
4051
			signature = ConstantPool.SET_BYTE_METHOD_SIGNATURE;
4145
			signature = ConstantPool.SET_BYTE_METHOD_SIGNATURE;
4146
			receiverAndArgsSize = 3;
4052
			break;
4147
			break;
4053
		case TypeIds.T_short :
4148
		case TypeIds.T_short :
4054
			selector = ConstantPool.SET_SHORT_METHOD_NAME;
4149
			selector = ConstantPool.SET_SHORT_METHOD_NAME;
4055
			signature = ConstantPool.SET_SHORT_METHOD_SIGNATURE;
4150
			signature = ConstantPool.SET_SHORT_METHOD_SIGNATURE;
4151
			receiverAndArgsSize = 3;
4056
			break;
4152
			break;
4057
		case TypeIds.T_long :
4153
		case TypeIds.T_long :
4058
			selector = ConstantPool.SET_LONG_METHOD_NAME;
4154
			selector = ConstantPool.SET_LONG_METHOD_NAME;
4059
			signature = ConstantPool.SET_LONG_METHOD_SIGNATURE;
4155
			signature = ConstantPool.SET_LONG_METHOD_SIGNATURE;
4060
			argCount = 3;
4156
			receiverAndArgsSize = 4;
4061
			break;
4157
			break;
4062
		case TypeIds.T_float :
4158
		case TypeIds.T_float :
4063
			selector = ConstantPool.SET_FLOAT_METHOD_NAME;
4159
			selector = ConstantPool.SET_FLOAT_METHOD_NAME;
4064
			signature = ConstantPool.SET_FLOAT_METHOD_SIGNATURE;
4160
			signature = ConstantPool.SET_FLOAT_METHOD_SIGNATURE;
4161
			receiverAndArgsSize = 3;
4065
			break;
4162
			break;
4066
		case TypeIds.T_double :
4163
		case TypeIds.T_double :
4067
			selector = ConstantPool.SET_DOUBLE_METHOD_NAME;
4164
			selector = ConstantPool.SET_DOUBLE_METHOD_NAME;
4068
			signature = ConstantPool.SET_DOUBLE_METHOD_SIGNATURE;
4165
			signature = ConstantPool.SET_DOUBLE_METHOD_SIGNATURE;
4069
			argCount = 3;
4166
			receiverAndArgsSize = 4;
4070
			break;
4167
			break;
4071
		case TypeIds.T_char :
4168
		case TypeIds.T_char :
4072
			selector = ConstantPool.SET_CHAR_METHOD_NAME;
4169
			selector = ConstantPool.SET_CHAR_METHOD_NAME;
4073
			signature = ConstantPool.SET_CHAR_METHOD_SIGNATURE;
4170
			signature = ConstantPool.SET_CHAR_METHOD_SIGNATURE;
4171
			receiverAndArgsSize = 3;
4074
			break;
4172
			break;
4075
		case TypeIds.T_boolean :
4173
		case TypeIds.T_boolean :
4076
			selector = ConstantPool.SET_BOOLEAN_METHOD_NAME;
4174
			selector = ConstantPool.SET_BOOLEAN_METHOD_NAME;
4077
			signature = ConstantPool.SET_BOOLEAN_METHOD_SIGNATURE;
4175
			signature = ConstantPool.SET_BOOLEAN_METHOD_SIGNATURE;
4176
			receiverAndArgsSize = 3;
4078
			break;
4177
			break;
4079
		default :
4178
		default :
4080
			selector = ConstantPool.SET_OBJECT_METHOD_NAME;
4179
			selector = ConstantPool.SET_OBJECT_METHOD_NAME;
4081
			signature = ConstantPool.SET_OBJECT_METHOD_SIGNATURE;
4180
			signature = ConstantPool.SET_OBJECT_METHOD_SIGNATURE;
4181
			receiverAndArgsSize = 3;
4082
			break;
4182
			break;
4083
	}
4183
	}
4084
	invoke(
4184
	invoke(
4085
			Opcodes.OPC_invokevirtual,
4185
			Opcodes.OPC_invokevirtual,
4086
			argCount, // argCount
4186
			receiverAndArgsSize,
4087
			0, // return type size
4187
			0, // return type size
4088
			ConstantPool.JAVALANGREFLECTFIELD_CONSTANTPOOLNAME,
4188
			ConstantPool.JAVALANGREFLECTFIELD_CONSTANTPOOLNAME,
4089
			selector,
4189
			selector,
4090
			signature);
4190
			signature);
4091
}
4191
}
4192
4092
public void invokeJavaLangReflectMethodInvoke() {
4193
public void invokeJavaLangReflectMethodInvoke() {
4093
	// invokevirtual: java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;
4194
	// invokevirtual: java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;
4094
	invoke(
4195
	invoke(
4095
			Opcodes.OPC_invokevirtual,
4196
			Opcodes.OPC_invokevirtual,
4096
			2, // argCount
4197
			3, // receiverAndArgsSize
4097
			1, // return type size
4198
			1, // return type size
4098
			ConstantPool.JAVALANGREFLECTMETHOD_CONSTANTPOOLNAME,
4199
			ConstantPool.JAVALANGREFLECTMETHOD_CONSTANTPOOLNAME,
4099
			ConstantPool.INVOKE_METHOD_METHOD_NAME,
4200
			ConstantPool.INVOKE_METHOD_METHOD_NAME,
4100
			ConstantPool.INVOKE_METHOD_METHOD_SIGNATURE);
4201
			ConstantPool.INVOKE_METHOD_METHOD_SIGNATURE);
4101
}
4202
}
4203
4102
public void invokeJavaUtilIteratorHasNext() {
4204
public void invokeJavaUtilIteratorHasNext() {
4103
	// invokeinterface java.util.Iterator.hasNext()Z
4205
	// invokeinterface java.util.Iterator.hasNext()Z
4104
	if (DEBUG) System.out.println(this.position + "\t\tinvokeinterface: java.util.Iterator.hasNext()Z"); //$NON-NLS-1$
4105
	invoke(
4206
	invoke(
4106
			Opcodes.OPC_invokeinterface,
4207
			Opcodes.OPC_invokeinterface,
4107
			0, // argCount
4208
			1, // receiverAndArgsSize
4108
			1, // return type size
4209
			1, // return type size
4109
			ConstantPool.JavaUtilIteratorConstantPoolName,
4210
			ConstantPool.JavaUtilIteratorConstantPoolName,
4110
			ConstantPool.HasNext,
4211
			ConstantPool.HasNext,
4111
			ConstantPool.HasNextSignature);
4212
			ConstantPool.HasNextSignature);
4112
}
4213
}
4214
4113
public void invokeJavaUtilIteratorNext() {
4215
public void invokeJavaUtilIteratorNext() {
4114
	// invokeinterface java.util.Iterator.next()java.lang.Object
4216
	// invokeinterface java.util.Iterator.next()java.lang.Object
4115
	if (DEBUG) System.out.println(this.position + "\t\tinvokeinterface: java.util.Iterator.next()java.lang.Object"); //$NON-NLS-1$
4116
	invoke(
4217
	invoke(
4117
			Opcodes.OPC_invokeinterface,
4218
			Opcodes.OPC_invokeinterface,
4118
			0, // argCount
4219
			1, // receiverAndArgsSize
4119
			1, // return type size
4220
			1, // return type size
4120
			ConstantPool.JavaUtilIteratorConstantPoolName,
4221
			ConstantPool.JavaUtilIteratorConstantPoolName,
4121
			ConstantPool.Next,
4222
			ConstantPool.Next,
4122
			ConstantPool.NextSignature);
4223
			ConstantPool.NextSignature);
4123
}
4224
}
4225
4124
public void invokeNoClassDefFoundErrorStringConstructor() {
4226
public void invokeNoClassDefFoundErrorStringConstructor() {
4125
	// invokespecial: java.lang.NoClassDefFoundError.<init>(Ljava.lang.String;)V
4227
	// invokespecial: java.lang.NoClassDefFoundError.<init>(Ljava.lang.String;)V
4126
	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial: java.lang.NoClassDefFoundError.<init>(Ljava.lang.String;)V"); //$NON-NLS-1$
4127
	invoke(
4228
	invoke(
4128
			Opcodes.OPC_invokespecial,
4229
			Opcodes.OPC_invokespecial,
4129
			1, // argCount
4230
			2, // receiverAndArgsSize
4130
			0, // return type size
4231
			0, // return type size
4131
			ConstantPool.JavaLangNoClassDefFoundErrorConstantPoolName,
4232
			ConstantPool.JavaLangNoClassDefFoundErrorConstantPoolName,
4132
			ConstantPool.Init,
4233
			ConstantPool.Init,
4133
			ConstantPool.StringConstructorSignature);
4234
			ConstantPool.StringConstructorSignature);
4134
}
4235
}
4236
4135
public void invokeObjectGetClass() {
4237
public void invokeObjectGetClass() {
4136
	// invokevirtual: java.lang.Object.getClass()Ljava.lang.Class;
4238
	// invokevirtual: java.lang.Object.getClass()Ljava.lang.Class;
4137
	if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: java.lang.Object.getClass()Ljava.lang.Class;"); //$NON-NLS-1$
4138
	invoke(
4239
	invoke(
4139
			Opcodes.OPC_invokevirtual,
4240
			Opcodes.OPC_invokevirtual,
4140
			0, // argCount
4241
			1, // receiverAndArgsSize
4141
			1, // return type size
4242
			1, // return type size
4142
			ConstantPool.JavaLangObjectConstantPoolName,
4243
			ConstantPool.JavaLangObjectConstantPoolName,
4143
			ConstantPool.GetClass,
4244
			ConstantPool.GetClass,
4144
			ConstantPool.GetClassSignature);
4245
			ConstantPool.GetClassSignature);
4145
}
4246
}
4146
public void invokespecial(MethodBinding methodBinding) {
4247
4147
	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial:"+methodBinding); //$NON-NLS-1$
4148
	this.countLabels = 0;
4149
	// initialized to 1 to take into account this immediately
4150
	int argCount = 1;
4151
	int id;
4152
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
4153
		resizeByteArray();
4154
	}
4155
	this.position++;
4156
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokespecial;
4157
	writeUnsignedShort(
4158
		this.constantPool.literalIndexForMethod(
4159
			methodBinding.constantPoolDeclaringClass(),
4160
			methodBinding.selector,
4161
			methodBinding.signature(this.classFile),
4162
			false));
4163
	if (methodBinding.isConstructor()) {
4164
		final ReferenceBinding declaringClass = methodBinding.declaringClass;
4165
		if (declaringClass.isNestedType()) {
4166
			// enclosing instances
4167
			TypeBinding[] syntheticArgumentTypes = declaringClass.syntheticEnclosingInstanceTypes();
4168
			if (syntheticArgumentTypes != null) {
4169
				for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
4170
					if (((id = syntheticArgumentTypes[i].id) == TypeIds.T_double) || (id == TypeIds.T_long)) {
4171
						argCount += 2;
4172
					} else {
4173
						argCount++;
4174
					}
4175
				}
4176
			}
4177
			// outer local variables
4178
			SyntheticArgumentBinding[] syntheticArguments = declaringClass.syntheticOuterLocalVariables();
4179
			if (syntheticArguments != null) {
4180
				for (int i = 0, max = syntheticArguments.length; i < max; i++) {
4181
					if (((id = syntheticArguments[i].type.id) == TypeIds.T_double) || (id == TypeIds.T_long)) {
4182
						argCount += 2;
4183
					} else {
4184
						argCount++;
4185
					}
4186
				}
4187
			}
4188
		}
4189
		if (declaringClass.isEnum()) {
4190
			// adding String and int
4191
			argCount += 2;
4192
		}
4193
	}
4194
	for (int i = methodBinding.parameters.length - 1; i >= 0; i--)
4195
		if (((id = methodBinding.parameters[i].id) == TypeIds.T_double) || (id == TypeIds.T_long))
4196
			argCount += 2;
4197
		else
4198
			argCount++;
4199
	if (((id = methodBinding.returnType.id) == TypeIds.T_double) || (id == TypeIds.T_long))
4200
		this.stackDepth += (2 - argCount);
4201
	else
4202
		if (id == TypeIds.T_void)
4203
			this.stackDepth -= argCount;
4204
		else
4205
			this.stackDepth += (1 - argCount);
4206
	if (this.stackDepth > this.stackMax)
4207
		this.stackMax = this.stackDepth;
4208
}
4209
public void invokestatic(MethodBinding methodBinding) {
4210
	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic:"+methodBinding); //$NON-NLS-1$
4211
	// initialized to 0 to take into account that there is no this for
4212
	// a static method
4213
	this.countLabels = 0;
4214
	int argCount = 0;
4215
	int id;
4216
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
4217
		resizeByteArray();
4218
	}
4219
	this.position++;
4220
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokestatic;
4221
	writeUnsignedShort(
4222
		this.constantPool.literalIndexForMethod(
4223
			methodBinding.constantPoolDeclaringClass(),
4224
			methodBinding.selector,
4225
			methodBinding.signature(this.classFile),
4226
			false));
4227
	for (int i = methodBinding.parameters.length - 1; i >= 0; i--)
4228
		if (((id = methodBinding.parameters[i].id) == TypeIds.T_double) || (id == TypeIds.T_long))
4229
			argCount += 2;
4230
		else
4231
			argCount += 1;
4232
	if (((id = methodBinding.returnType.id) == TypeIds.T_double) || (id == TypeIds.T_long))
4233
		this.stackDepth += (2 - argCount);
4234
	else
4235
		if (id == TypeIds.T_void)
4236
			this.stackDepth -= argCount;
4237
		else
4238
			this.stackDepth += (1 - argCount);
4239
	if (this.stackDepth > this.stackMax)
4240
		this.stackMax = this.stackDepth;
4241
}
4242
/**
4248
/**
4243
 * The equivalent code performs a string conversion of the TOS
4249
 * The equivalent code performs a string conversion of the TOS
4244
 * @param typeID <CODE>int</CODE>
4250
 * @param typeID <CODE>int</CODE>
4245
 */
4251
 */
4246
public void invokeStringConcatenationAppendForType(int typeID) {
4252
public void invokeStringConcatenationAppendForType(int typeID) {
4247
	if (DEBUG) {
4253
	int receiverAndArgsSize;
4248
		if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4249
			System.out.println(this.position + "\t\tinvokevirtual: java.lang.StringBuilder.append(...)"); //$NON-NLS-1$
4250
		} else {
4251
			System.out.println(this.position + "\t\tinvokevirtual: java.lang.StringBuffer.append(...)"); //$NON-NLS-1$
4252
		}
4253
	}
4254
	int argCount = 1;
4255
	int returnType = 1;
4256
	char[] declaringClass = null;
4254
	char[] declaringClass = null;
4257
	char[] selector = ConstantPool.Append;
4255
	char[] selector = ConstantPool.Append;
4258
	char[] signature = null;
4256
	char[] signature = null;
Lines 4267-4272 Link Here
4267
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4265
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4268
				signature = ConstantPool.StringBufferAppendIntSignature;
4266
				signature = ConstantPool.StringBufferAppendIntSignature;
4269
			}
4267
			}
4268
			receiverAndArgsSize = 2;
4270
			break;
4269
			break;
4271
		case TypeIds.T_long :
4270
		case TypeIds.T_long :
4272
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4271
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
Lines 4276-4282 Link Here
4276
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4275
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4277
				signature = ConstantPool.StringBufferAppendLongSignature;
4276
				signature = ConstantPool.StringBufferAppendLongSignature;
4278
			}
4277
			}
4279
			argCount = 2;
4278
			receiverAndArgsSize = 3;
4280
			break;
4279
			break;
4281
		case TypeIds.T_float :
4280
		case TypeIds.T_float :
4282
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4281
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
Lines 4286-4291 Link Here
4286
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4285
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4287
				signature = ConstantPool.StringBufferAppendFloatSignature;
4286
				signature = ConstantPool.StringBufferAppendFloatSignature;
4288
			}
4287
			}
4288
			receiverAndArgsSize = 2;
4289
			break;
4289
			break;
4290
		case TypeIds.T_double :
4290
		case TypeIds.T_double :
4291
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4291
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
Lines 4295-4301 Link Here
4295
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4295
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4296
				signature = ConstantPool.StringBufferAppendDoubleSignature;
4296
				signature = ConstantPool.StringBufferAppendDoubleSignature;
4297
			}
4297
			}
4298
			argCount = 2;
4298
			receiverAndArgsSize = 3;
4299
			break;
4299
			break;
4300
		case TypeIds.T_char :
4300
		case TypeIds.T_char :
4301
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4301
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
Lines 4305-4310 Link Here
4305
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4305
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4306
				signature = ConstantPool.StringBufferAppendCharSignature;
4306
				signature = ConstantPool.StringBufferAppendCharSignature;
4307
			}
4307
			}
4308
			receiverAndArgsSize = 2;
4308
			break;
4309
			break;
4309
		case TypeIds.T_boolean :
4310
		case TypeIds.T_boolean :
4310
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4311
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
Lines 4314-4520 Link Here
4314
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4315
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4315
				signature = ConstantPool.StringBufferAppendBooleanSignature;
4316
				signature = ConstantPool.StringBufferAppendBooleanSignature;
4316
			}
4317
			}
4318
			receiverAndArgsSize = 2;
4317
			break;
4319
			break;
4318
		case TypeIds.T_undefined :
4320
		case TypeIds.T_JavaLangString :
4319
		case TypeIds.T_JavaLangObject :
4320
		case TypeIds.T_null :
4321
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4321
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4322
				declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName;
4322
				declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName;
4323
				signature = ConstantPool.StringBuilderAppendObjectSignature;
4323
				signature = ConstantPool.StringBuilderAppendStringSignature;
4324
			} else {
4324
			} else {
4325
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4325
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4326
				signature = ConstantPool.StringBufferAppendObjectSignature;
4326
				signature = ConstantPool.StringBufferAppendStringSignature;
4327
			}
4327
			}
4328
			receiverAndArgsSize = 2;
4328
			break;
4329
			break;
4329
		case TypeIds.T_JavaLangString :
4330
		default :
4330
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4331
			if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4331
				declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName;
4332
				declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName;
4332
				signature = ConstantPool.StringBuilderAppendStringSignature;
4333
				signature = ConstantPool.StringBuilderAppendObjectSignature;
4333
			} else {
4334
			} else {
4334
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4335
				declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4335
				signature = ConstantPool.StringBufferAppendStringSignature;
4336
				signature = ConstantPool.StringBufferAppendObjectSignature;
4336
			}
4337
			}
4338
			receiverAndArgsSize = 2;
4337
			break;
4339
			break;
4338
	}
4340
	}
4339
	invoke(
4341
	invoke(
4340
			Opcodes.OPC_invokevirtual,
4342
			Opcodes.OPC_invokevirtual,
4341
			argCount, // argCount
4343
			receiverAndArgsSize,
4342
			returnType, // return type size
4344
			1, // return type size
4343
			declaringClass,
4345
			declaringClass,
4344
			selector,
4346
			selector,
4345
			signature);
4347
			signature);
4346
}
4348
}
4349
4347
public void invokeStringConcatenationDefaultConstructor() {
4350
public void invokeStringConcatenationDefaultConstructor() {
4348
	// invokespecial: java.lang.StringBuffer.<init>()V
4351
	// invokespecial: java.lang.StringBuffer.<init>()V
4349
	if (DEBUG) {
4352
	// or invokespecial: java.lang.StringBuilder.<init>()V
4350
		if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4353
	char[] declaringClass;
4351
			System.out.println(this.position + "\t\tinvokespecial: java.lang.StringBuilder.<init>()V"); //$NON-NLS-1$
4354
	if (this.targetLevel < ClassFileConstants.JDK1_5) {
4352
		} else {
4355
		declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4353
			System.out.println(this.position + "\t\tinvokespecial: java.lang.StringBuffer.<init>()V"); //$NON-NLS-1$
4356
	} else {
4354
		}
4355
	}
4356
	char[] declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4357
	if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4358
		declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName;
4357
		declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName;
4359
	}
4358
	}
4360
	invoke(
4359
	invoke(
4361
			Opcodes.OPC_invokespecial,
4360
			Opcodes.OPC_invokespecial,
4362
			0, // argCount
4361
			1, // receiverAndArgsSize
4363
			0, // return type size
4362
			0, // return type size
4364
			declaringClass,
4363
			declaringClass,
4365
			ConstantPool.Init,
4364
			ConstantPool.Init,
4366
			ConstantPool.DefaultConstructorSignature);
4365
			ConstantPool.DefaultConstructorSignature);
4367
}
4366
}
4367
4368
public void invokeStringConcatenationStringConstructor() {
4368
public void invokeStringConcatenationStringConstructor() {
4369
	if (DEBUG) {
4369
	// invokespecial: java.lang.StringBuffer.<init>(java.lang.String)V
4370
		if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4370
	// or invokespecial: java.lang.StringBuilder.<init>(java.lang.String)V
4371
			System.out.println(this.position + "\t\tjava.lang.StringBuilder.<init>(Ljava.lang.String;)V"); //$NON-NLS-1$
4371
	char[] declaringClass;
4372
		} else {
4372
	if (this.targetLevel < ClassFileConstants.JDK1_5) {
4373
			System.out.println(this.position + "\t\tjava.lang.StringBuffer.<init>(Ljava.lang.String;)V"); //$NON-NLS-1$
4373
		// invokespecial: java.lang.StringBuffer.<init>()V
4374
		}
4374
		declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4375
	}
4375
	} else {
4376
	char[] declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4376
		// invokespecial: java.lang.StringStringBuilder.<init>(java.langString)V
4377
	if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4378
		declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName;
4377
		declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName;
4379
	}
4378
	}
4380
	invoke(
4379
	invoke(
4381
			Opcodes.OPC_invokespecial,
4380
			Opcodes.OPC_invokespecial,
4382
			1, // argCount
4381
			2, // receiverAndArgsSize
4383
			0, // return type size
4382
			0, // return type size
4384
			declaringClass,
4383
			declaringClass,
4385
			ConstantPool.Init,
4384
			ConstantPool.Init,
4386
			ConstantPool.StringConstructorSignature);
4385
			ConstantPool.StringConstructorSignature);
4387
}
4386
}
4387
4388
public void invokeStringConcatenationToString() {
4388
public void invokeStringConcatenationToString() {
4389
	if (DEBUG) {
4389
	// invokespecial: java.lang.StringBuffer.toString()java.lang.String
4390
		if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4390
	// or invokespecial: java.lang.StringBuilder.toString()java.lang.String
4391
			System.out.println(this.position + "\t\tinvokevirtual: StringBuilder.toString()Ljava.lang.String;"); //$NON-NLS-1$
4391
	char[] declaringClass;
4392
		} else {
4392
	if (this.targetLevel < ClassFileConstants.JDK1_5) {
4393
			System.out.println(this.position + "\t\tinvokevirtual: StringBuffer.toString()Ljava.lang.String;"); //$NON-NLS-1$
4393
		// invokespecial: java.lang.StringBuffer.<init>()V
4394
		}
4394
		declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4395
	}
4395
	} else {
4396
	char[] declaringClass = ConstantPool.JavaLangStringBufferConstantPoolName;
4396
		// invokespecial: java.lang.StringStringBuilder.<init>(java.langString)V
4397
	if (this.targetLevel >= ClassFileConstants.JDK1_5) {
4398
		declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName;
4397
		declaringClass = ConstantPool.JavaLangStringBuilderConstantPoolName;
4399
	}
4398
	}	
4400
	invoke(
4399
	invoke(
4401
			Opcodes.OPC_invokevirtual,
4400
			Opcodes.OPC_invokevirtual,
4402
			0, // argCount
4401
			1, // receiverAndArgsSize
4403
			1, // return type size
4402
			1, // return type size
4404
			declaringClass,
4403
			declaringClass,
4405
			ConstantPool.ToString,
4404
			ConstantPool.ToString,
4406
			ConstantPool.ToStringSignature);
4405
			ConstantPool.ToStringSignature);
4407
}
4406
}
4407
4408
public void invokeStringIntern() {
4408
public void invokeStringIntern() {
4409
	// invokevirtual: java.lang.String.intern()
4409
	// invokevirtual: java.lang.String.intern()
4410
	if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: java.lang.String.intern()"); //$NON-NLS-1$
4411
	invoke(
4410
	invoke(
4412
			Opcodes.OPC_invokevirtual,
4411
			Opcodes.OPC_invokevirtual,
4413
			0, // argCount
4412
			1, // receiverAndArgsSize
4414
			1, // return type size
4413
			1, // return type size
4415
			ConstantPool.JavaLangStringConstantPoolName,
4414
			ConstantPool.JavaLangStringConstantPoolName,
4416
			ConstantPool.Intern,
4415
			ConstantPool.Intern,
4417
			ConstantPool.InternSignature);
4416
			ConstantPool.InternSignature);
4418
}
4417
}
4418
4419
public void invokeStringValueOf(int typeID) {
4419
public void invokeStringValueOf(int typeID) {
4420
	// invokestatic: java.lang.String.valueOf(argumentType)
4420
	// invokestatic: java.lang.String.valueOf(argumentType)
4421
	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic: java.lang.String.valueOf(...)"); //$NON-NLS-1$
4421
	char[] signature;
4422
	int argCount = 1;
4422
	int receiverAndArgsSize;
4423
	char[] signature = null;
4424
	switch (typeID) {
4423
	switch (typeID) {
4425
		case TypeIds.T_int :
4424
		case TypeIds.T_int :
4426
		case TypeIds.T_byte :
4425
		case TypeIds.T_byte :
4427
		case TypeIds.T_short :
4426
		case TypeIds.T_short :
4428
			signature = ConstantPool.ValueOfIntSignature;
4427
			signature = ConstantPool.ValueOfIntSignature;
4428
			receiverAndArgsSize = 1;
4429
			break;
4429
			break;
4430
		case TypeIds.T_long :
4430
		case TypeIds.T_long :
4431
			signature = ConstantPool.ValueOfLongSignature;
4431
			signature = ConstantPool.ValueOfLongSignature;
4432
			argCount = 2;
4432
			receiverAndArgsSize = 2;
4433
			break;
4433
			break;
4434
		case TypeIds.T_float :
4434
		case TypeIds.T_float :
4435
			signature = ConstantPool.ValueOfFloatSignature;
4435
			signature = ConstantPool.ValueOfFloatSignature;
4436
			receiverAndArgsSize = 1;
4436
			break;
4437
			break;
4437
		case TypeIds.T_double :
4438
		case TypeIds.T_double :
4438
			signature = ConstantPool.ValueOfDoubleSignature;
4439
			signature = ConstantPool.ValueOfDoubleSignature;
4439
			argCount = 2;
4440
			receiverAndArgsSize = 2;
4440
			break;
4441
			break;
4441
		case TypeIds.T_char :
4442
		case TypeIds.T_char :
4442
			signature = ConstantPool.ValueOfCharSignature;
4443
			signature = ConstantPool.ValueOfCharSignature;
4444
			receiverAndArgsSize = 1;
4443
			break;
4445
			break;
4444
		case TypeIds.T_boolean :
4446
		case TypeIds.T_boolean :
4445
			signature = ConstantPool.ValueOfBooleanSignature;
4447
			signature = ConstantPool.ValueOfBooleanSignature;
4448
			receiverAndArgsSize = 1;
4446
			break;
4449
			break;
4447
		case TypeIds.T_JavaLangObject :
4450
		case TypeIds.T_JavaLangObject :
4448
		case TypeIds.T_JavaLangString :
4451
		case TypeIds.T_JavaLangString :
4449
		case TypeIds.T_null :
4452
		case TypeIds.T_null :
4450
		case TypeIds.T_undefined :
4453
		case TypeIds.T_undefined :
4451
			signature = ConstantPool.ValueOfObjectSignature;
4454
			signature = ConstantPool.ValueOfObjectSignature;
4455
			receiverAndArgsSize = 1;
4452
			break;
4456
			break;
4457
		default :
4458
			return; // should not occur
4453
	}
4459
	}
4454
	invoke(
4460
	invoke(
4455
			Opcodes.OPC_invokestatic,
4461
			Opcodes.OPC_invokestatic,
4456
			argCount, // argCount
4462
			receiverAndArgsSize, // receiverAndArgsSize
4457
			1, // return type size
4463
			1, // return type size
4458
			ConstantPool.JavaLangStringConstantPoolName,
4464
			ConstantPool.JavaLangStringConstantPoolName,
4459
			ConstantPool.ValueOf,
4465
			ConstantPool.ValueOf,
4460
			signature);
4466
			signature);
4461
}
4467
}
4468
4462
public void invokeSystemArraycopy() {
4469
public void invokeSystemArraycopy() {
4463
	// invokestatic #21 <Method java/lang/System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V>
4470
	// invokestatic #21 <Method java/lang/System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V>
4464
	if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V"); //$NON-NLS-1$
4465
	invoke(
4471
	invoke(
4466
			Opcodes.OPC_invokestatic,
4472
			Opcodes.OPC_invokestatic,
4467
			5, // argCount
4473
			5, // receiverAndArgsSize
4468
			0, // return type size
4474
			0, // return type size
4469
			ConstantPool.JavaLangSystemConstantPoolName,
4475
			ConstantPool.JavaLangSystemConstantPoolName,
4470
			ConstantPool.ArrayCopy,
4476
			ConstantPool.ArrayCopy,
4471
			ConstantPool.ArrayCopySignature);
4477
			ConstantPool.ArrayCopySignature);
4472
}
4478
}
4479
4473
public void invokeThrowableGetMessage() {
4480
public void invokeThrowableGetMessage() {
4474
	// invokevirtual: java.lang.Throwable.getMessage()Ljava.lang.String;
4481
	// invokevirtual: java.lang.Throwable.getMessage()Ljava.lang.String;
4475
	if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual: java.lang.Throwable.getMessage()Ljava.lang.String;"); //$NON-NLS-1$
4476
	invoke(
4482
	invoke(
4477
			Opcodes.OPC_invokevirtual,
4483
			Opcodes.OPC_invokevirtual,
4478
			0, // argCount
4484
			1, // receiverAndArgsSize
4479
			1, // return type size
4485
			1, // return type size
4480
			ConstantPool.JavaLangThrowableConstantPoolName,
4486
			ConstantPool.JavaLangThrowableConstantPoolName,
4481
			ConstantPool.GetMessage,
4487
			ConstantPool.GetMessage,
4482
			ConstantPool.GetMessageSignature);
4488
			ConstantPool.GetMessageSignature);
4483
}
4489
}
4484
public void invokevirtual(MethodBinding methodBinding) {
4490
4485
	if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual:"+methodBinding); //$NON-NLS-1$
4486
	this.countLabels = 0;
4487
	// initialized to 1 to take into account this  immediately
4488
	int argCount = 1;
4489
	int id;
4490
	if (this.classFileOffset + 2 >= this.bCodeStream.length) {
4491
		resizeByteArray();
4492
	}
4493
	this.position++;
4494
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokevirtual;
4495
	writeUnsignedShort(
4496
		this.constantPool.literalIndexForMethod(
4497
			methodBinding.constantPoolDeclaringClass(),
4498
			methodBinding.selector,
4499
			methodBinding.signature(this.classFile),
4500
			false));
4501
	for (int i = methodBinding.parameters.length - 1; i >= 0; i--)
4502
		if (((id = methodBinding.parameters[i].id) == TypeIds.T_double) || (id == TypeIds.T_long))
4503
			argCount += 2;
4504
		else
4505
			argCount++;
4506
	if (((id = methodBinding.returnType.id) == TypeIds.T_double) || (id == TypeIds.T_long))
4507
		this.stackDepth += (2 - argCount);
4508
	else
4509
		if (id == TypeIds.T_void)
4510
			this.stackDepth -= argCount;
4511
		else
4512
			this.stackDepth += (1 - argCount);
4513
	if (this.stackDepth > this.stackMax)
4514
		this.stackMax = this.stackDepth;
4515
}
4516
public void ior() {
4491
public void ior() {
4517
	if (DEBUG) System.out.println(this.position + "\t\tior"); //$NON-NLS-1$
4518
	this.countLabels = 0;
4492
	this.countLabels = 0;
4519
	this.stackDepth--;
4493
	this.stackDepth--;
4520
	if (this.classFileOffset >= this.bCodeStream.length) {
4494
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4523-4530 Link Here
4523
	this.position++;
4497
	this.position++;
4524
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ior;
4498
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ior;
4525
}
4499
}
4500
4526
public void irem() {
4501
public void irem() {
4527
	if (DEBUG) System.out.println(this.position + "\t\tirem"); //$NON-NLS-1$
4528
	this.countLabels = 0;
4502
	this.countLabels = 0;
4529
	this.stackDepth--;
4503
	this.stackDepth--;
4530
	if (this.classFileOffset >= this.bCodeStream.length) {
4504
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4533-4540 Link Here
4533
	this.position++;
4507
	this.position++;
4534
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_irem;
4508
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_irem;
4535
}
4509
}
4510
4536
public void ireturn() {
4511
public void ireturn() {
4537
	if (DEBUG) System.out.println(this.position + "\t\tireturn"); //$NON-NLS-1$
4538
	this.countLabels = 0;
4512
	this.countLabels = 0;
4539
	this.stackDepth--;
4513
	this.stackDepth--;
4540
	// the stackDepth should be equal to 0
4514
	// the stackDepth should be equal to 0
Lines 4545-4550 Link Here
4545
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ireturn;
4519
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ireturn;
4546
	this.lastAbruptCompletion = this.position;
4520
	this.lastAbruptCompletion = this.position;
4547
}
4521
}
4522
4548
public boolean isDefinitelyAssigned(Scope scope, int initStateIndex, LocalVariableBinding local) {
4523
public boolean isDefinitelyAssigned(Scope scope, int initStateIndex, LocalVariableBinding local) {
4549
	// Mirror of UnconditionalFlowInfo.isDefinitelyAssigned(..)
4524
	// Mirror of UnconditionalFlowInfo.isDefinitelyAssigned(..)
4550
	if ((local.tagBits & TagBits.IsArgument) != 0) {
4525
	if ((local.tagBits & TagBits.IsArgument) != 0) {
Lines 4567-4574 Link Here
4567
		return false; // if not enough room in vector, then not initialized
4542
		return false; // if not enough room in vector, then not initialized
4568
	return ((extraInits[vectorIndex]) & (1L << (localPosition % UnconditionalFlowInfo.BitCacheSize))) != 0;
4543
	return ((extraInits[vectorIndex]) & (1L << (localPosition % UnconditionalFlowInfo.BitCacheSize))) != 0;
4569
}
4544
}
4545
4570
public void ishl() {
4546
public void ishl() {
4571
	if (DEBUG) System.out.println(this.position + "\t\tishl"); //$NON-NLS-1$
4572
	this.countLabels = 0;
4547
	this.countLabels = 0;
4573
	this.stackDepth--;
4548
	this.stackDepth--;
4574
	if (this.classFileOffset >= this.bCodeStream.length) {
4549
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4577-4584 Link Here
4577
	this.position++;
4552
	this.position++;
4578
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ishl;
4553
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ishl;
4579
}
4554
}
4555
4580
public void ishr() {
4556
public void ishr() {
4581
	if (DEBUG) System.out.println(this.position + "\t\tishr"); //$NON-NLS-1$
4582
	this.countLabels = 0;
4557
	this.countLabels = 0;
4583
	this.stackDepth--;
4558
	this.stackDepth--;
4584
	if (this.classFileOffset >= this.bCodeStream.length) {
4559
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4587-4594 Link Here
4587
	this.position++;
4562
	this.position++;
4588
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ishr;
4563
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ishr;
4589
}
4564
}
4565
4590
public void istore(int iArg) {
4566
public void istore(int iArg) {
4591
	if (DEBUG) System.out.println(this.position + "\t\tistore:"+iArg); //$NON-NLS-1$
4592
	this.countLabels = 0;
4567
	this.countLabels = 0;
4593
	this.stackDepth--;
4568
	this.stackDepth--;
4594
	if (this.maxLocals <= iArg) {
4569
	if (this.maxLocals <= iArg) {
Lines 4611-4618 Link Here
4611
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
4586
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
4612
	}
4587
	}
4613
}
4588
}
4589
4614
public void istore_0() {
4590
public void istore_0() {
4615
	if (DEBUG) System.out.println(this.position + "\t\tistore_0"); //$NON-NLS-1$
4616
	this.countLabels = 0;
4591
	this.countLabels = 0;
4617
	this.stackDepth--;
4592
	this.stackDepth--;
4618
	if (this.maxLocals == 0) {
4593
	if (this.maxLocals == 0) {
Lines 4624-4631 Link Here
4624
	this.position++;
4599
	this.position++;
4625
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_0;
4600
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_0;
4626
}
4601
}
4602
4627
public void istore_1() {
4603
public void istore_1() {
4628
	if (DEBUG) System.out.println(this.position + "\t\tistore_1"); //$NON-NLS-1$
4629
	this.countLabels = 0;
4604
	this.countLabels = 0;
4630
	this.stackDepth--;
4605
	this.stackDepth--;
4631
	if (this.maxLocals <= 1) {
4606
	if (this.maxLocals <= 1) {
Lines 4637-4644 Link Here
4637
	this.position++;
4612
	this.position++;
4638
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_1;
4613
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_1;
4639
}
4614
}
4615
4640
public void istore_2() {
4616
public void istore_2() {
4641
	if (DEBUG) System.out.println(this.position + "\t\tistore_2"); //$NON-NLS-1$
4642
	this.countLabels = 0;
4617
	this.countLabels = 0;
4643
	this.stackDepth--;
4618
	this.stackDepth--;
4644
	if (this.maxLocals <= 2) {
4619
	if (this.maxLocals <= 2) {
Lines 4650-4657 Link Here
4650
	this.position++;
4625
	this.position++;
4651
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_2;
4626
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_2;
4652
}
4627
}
4628
4653
public void istore_3() {
4629
public void istore_3() {
4654
	if (DEBUG) System.out.println(this.position + "\t\tistore_3"); //$NON-NLS-1$
4655
	this.countLabels = 0;
4630
	this.countLabels = 0;
4656
	this.stackDepth--;
4631
	this.stackDepth--;
4657
	if (this.maxLocals <= 3) {
4632
	if (this.maxLocals <= 3) {
Lines 4663-4670 Link Here
4663
	this.position++;
4638
	this.position++;
4664
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_3;
4639
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_istore_3;
4665
}
4640
}
4641
4666
public void isub() {
4642
public void isub() {
4667
	if (DEBUG) System.out.println(this.position + "\t\tisub"); //$NON-NLS-1$
4668
	this.countLabels = 0;
4643
	this.countLabels = 0;
4669
	this.stackDepth--;
4644
	this.stackDepth--;
4670
	if (this.classFileOffset >= this.bCodeStream.length) {
4645
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4673-4680 Link Here
4673
	this.position++;
4648
	this.position++;
4674
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_isub;
4649
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_isub;
4675
}
4650
}
4651
4676
public void iushr() {
4652
public void iushr() {
4677
	if (DEBUG) System.out.println(this.position + "\t\tiushr"); //$NON-NLS-1$
4678
	this.countLabels = 0;
4653
	this.countLabels = 0;
4679
	this.stackDepth--;
4654
	this.stackDepth--;
4680
	if (this.classFileOffset >= this.bCodeStream.length) {
4655
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4683-4690 Link Here
4683
	this.position++;
4658
	this.position++;
4684
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iushr;
4659
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_iushr;
4685
}
4660
}
4661
4686
public void ixor() {
4662
public void ixor() {
4687
	if (DEBUG) System.out.println(this.position + "\t\tixor"); //$NON-NLS-1$
4688
	this.countLabels = 0;
4663
	this.countLabels = 0;
4689
	this.stackDepth--;
4664
	this.stackDepth--;
4690
	if (this.classFileOffset >= this.bCodeStream.length) {
4665
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4693-4704 Link Here
4693
	this.position++;
4668
	this.position++;
4694
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ixor;
4669
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ixor;
4695
}
4670
}
4671
4696
final public void jsr(BranchLabel lbl) {
4672
final public void jsr(BranchLabel lbl) {
4697
	if (this.wideMode) {
4673
	if (this.wideMode) {
4698
		jsr_w(lbl);
4674
		jsr_w(lbl);
4699
		return;
4675
		return;
4700
	}
4676
	}
4701
	if (DEBUG) System.out.println(this.position + "\t\tjsr"+lbl); //$NON-NLS-1$
4702
	this.countLabels = 0;
4677
	this.countLabels = 0;
4703
	if (this.classFileOffset >= this.bCodeStream.length) {
4678
	if (this.classFileOffset >= this.bCodeStream.length) {
4704
		resizeByteArray();
4679
		resizeByteArray();
Lines 4707-4714 Link Here
4707
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_jsr;
4682
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_jsr;
4708
	lbl.branch();
4683
	lbl.branch();
4709
}
4684
}
4685
4710
final public void jsr_w(BranchLabel lbl) {
4686
final public void jsr_w(BranchLabel lbl) {
4711
	if (DEBUG) System.out.println(this.position + "\t\tjsr_w"+lbl); //$NON-NLS-1$
4712
	this.countLabels = 0;
4687
	this.countLabels = 0;
4713
	if (this.classFileOffset >= this.bCodeStream.length) {
4688
	if (this.classFileOffset >= this.bCodeStream.length) {
4714
		resizeByteArray();
4689
		resizeByteArray();
Lines 4717-4724 Link Here
4717
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_jsr_w;
4692
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_jsr_w;
4718
	lbl.branchWide();
4693
	lbl.branchWide();
4719
}
4694
}
4695
4720
public void l2d() {
4696
public void l2d() {
4721
	if (DEBUG) System.out.println(this.position + "\t\tl2d"); //$NON-NLS-1$
4722
	this.countLabels = 0;
4697
	this.countLabels = 0;
4723
	if (this.classFileOffset >= this.bCodeStream.length) {
4698
	if (this.classFileOffset >= this.bCodeStream.length) {
4724
		resizeByteArray();
4699
		resizeByteArray();
Lines 4726-4733 Link Here
4726
	this.position++;
4701
	this.position++;
4727
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_l2d;
4702
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_l2d;
4728
}
4703
}
4704
4729
public void l2f() {
4705
public void l2f() {
4730
	if (DEBUG) System.out.println(this.position + "\t\tl2f"); //$NON-NLS-1$
4731
	this.countLabels = 0;
4706
	this.countLabels = 0;
4732
	this.stackDepth--;
4707
	this.stackDepth--;
4733
	if (this.classFileOffset >= this.bCodeStream.length) {
4708
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4736-4743 Link Here
4736
	this.position++;
4711
	this.position++;
4737
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_l2f;
4712
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_l2f;
4738
}
4713
}
4714
4739
public void l2i() {
4715
public void l2i() {
4740
	if (DEBUG) System.out.println(this.position + "\t\tl2i"); //$NON-NLS-1$
4741
	this.countLabels = 0;
4716
	this.countLabels = 0;
4742
	this.stackDepth--;
4717
	this.stackDepth--;
4743
	if (this.classFileOffset >= this.bCodeStream.length) {
4718
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4746-4753 Link Here
4746
	this.position++;
4721
	this.position++;
4747
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_l2i;
4722
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_l2i;
4748
}
4723
}
4724
4749
public void ladd() {
4725
public void ladd() {
4750
	if (DEBUG) System.out.println(this.position + "\t\tladd"); //$NON-NLS-1$
4751
	this.countLabels = 0;
4726
	this.countLabels = 0;
4752
	this.stackDepth -= 2;
4727
	this.stackDepth -= 2;
4753
	if (this.classFileOffset >= this.bCodeStream.length) {
4728
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4756-4763 Link Here
4756
	this.position++;
4731
	this.position++;
4757
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ladd;
4732
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ladd;
4758
}
4733
}
4734
4759
public void laload() {
4735
public void laload() {
4760
	if (DEBUG) System.out.println(this.position + "\t\tlaload"); //$NON-NLS-1$
4761
	this.countLabels = 0;
4736
	this.countLabels = 0;
4762
	if (this.classFileOffset >= this.bCodeStream.length) {
4737
	if (this.classFileOffset >= this.bCodeStream.length) {
4763
		resizeByteArray();
4738
		resizeByteArray();
Lines 4765-4772 Link Here
4765
	this.position++;
4740
	this.position++;
4766
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_laload;
4741
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_laload;
4767
}
4742
}
4743
4768
public void land() {
4744
public void land() {
4769
	if (DEBUG) System.out.println(this.position + "\t\tland"); //$NON-NLS-1$
4770
	this.countLabels = 0;
4745
	this.countLabels = 0;
4771
	this.stackDepth -= 2;
4746
	this.stackDepth -= 2;
4772
	if (this.classFileOffset >= this.bCodeStream.length) {
4747
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4775-4782 Link Here
4775
	this.position++;
4750
	this.position++;
4776
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_land;
4751
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_land;
4777
}
4752
}
4753
4778
public void lastore() {
4754
public void lastore() {
4779
	if (DEBUG) System.out.println(this.position + "\t\tlastore"); //$NON-NLS-1$
4780
	this.countLabels = 0;
4755
	this.countLabels = 0;
4781
	this.stackDepth -= 4;
4756
	this.stackDepth -= 4;
4782
	if (this.classFileOffset >= this.bCodeStream.length) {
4757
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4785-4792 Link Here
4785
	this.position++;
4760
	this.position++;
4786
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lastore;
4761
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lastore;
4787
}
4762
}
4763
4788
public void lcmp() {
4764
public void lcmp() {
4789
	if (DEBUG) System.out.println(this.position + "\t\tlcmp"); //$NON-NLS-1$
4790
	this.countLabels = 0;
4765
	this.countLabels = 0;
4791
	this.stackDepth -= 3;
4766
	this.stackDepth -= 3;
4792
	if (this.classFileOffset >= this.bCodeStream.length) {
4767
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 4795-4802 Link Here
4795
	this.position++;
4770
	this.position++;
4796
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lcmp;
4771
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lcmp;
4797
}
4772
}
4773
4798
public void lconst_0() {
4774
public void lconst_0() {
4799
	if (DEBUG) System.out.println(this.position + "\t\tlconst_0"); //$NON-NLS-1$
4800
	this.countLabels = 0;
4775
	this.countLabels = 0;
4801
	this.stackDepth += 2;
4776
	this.stackDepth += 2;
4802
	if (this.stackDepth > this.stackMax)
4777
	if (this.stackDepth > this.stackMax)
Lines 4807-4814 Link Here
4807
	this.position++;
4782
	this.position++;
4808
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lconst_0;
4783
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lconst_0;
4809
}
4784
}
4785
4810
public void lconst_1() {
4786
public void lconst_1() {
4811
	if (DEBUG) System.out.println(this.position + "\t\tlconst_1"); //$NON-NLS-1$
4812
	this.countLabels = 0;
4787
	this.countLabels = 0;
4813
	this.stackDepth += 2;
4788
	this.stackDepth += 2;
4814
	if (this.stackDepth > this.stackMax)
4789
	if (this.stackDepth > this.stackMax)
Lines 4819-4824 Link Here
4819
	this.position++;
4794
	this.position++;
4820
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lconst_1;
4795
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lconst_1;
4821
}
4796
}
4797
4822
public void ldc(float constant) {
4798
public void ldc(float constant) {
4823
	this.countLabels = 0;
4799
	this.countLabels = 0;
4824
	int index = this.constantPool.literalIndex(constant);
4800
	int index = this.constantPool.literalIndex(constant);
Lines 4826-4832 Link Here
4826
	if (this.stackDepth > this.stackMax)
4802
	if (this.stackDepth > this.stackMax)
4827
		this.stackMax = this.stackDepth;
4803
		this.stackMax = this.stackDepth;
4828
	if (index > 255) {
4804
	if (index > 255) {
4829
		if (DEBUG) System.out.println(this.position + "\t\tldc_w:"+constant); //$NON-NLS-1$
4830
		// Generate a ldc_w
4805
		// Generate a ldc_w
4831
		if (this.classFileOffset + 2 >= this.bCodeStream.length) {
4806
		if (this.classFileOffset + 2 >= this.bCodeStream.length) {
4832
			resizeByteArray();
4807
			resizeByteArray();
Lines 4835-4841 Link Here
4835
		this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc_w;
4810
		this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc_w;
4836
		writeUnsignedShort(index);
4811
		writeUnsignedShort(index);
4837
	} else {
4812
	} else {
4838
		if (DEBUG) System.out.println(this.position + "\t\tldc:"+constant); //$NON-NLS-1$
4839
		// Generate a ldc
4813
		// Generate a ldc
4840
		if (this.classFileOffset + 1 >= this.bCodeStream.length) {
4814
		if (this.classFileOffset + 1 >= this.bCodeStream.length) {
4841
			resizeByteArray();
4815
			resizeByteArray();
Lines 4845-4850 Link Here
4845
		this.bCodeStream[this.classFileOffset++] = (byte) index;
4819
		this.bCodeStream[this.classFileOffset++] = (byte) index;
4846
	}
4820
	}
4847
}
4821
}
4822
4848
public void ldc(int constant) {
4823
public void ldc(int constant) {
4849
	this.countLabels = 0;
4824
	this.countLabels = 0;
4850
	int index = this.constantPool.literalIndex(constant);
4825
	int index = this.constantPool.literalIndex(constant);
Lines 4852-4858 Link Here
4852
	if (this.stackDepth > this.stackMax)
4827
	if (this.stackDepth > this.stackMax)
4853
		this.stackMax = this.stackDepth;
4828
		this.stackMax = this.stackDepth;
4854
	if (index > 255) {
4829
	if (index > 255) {
4855
		if (DEBUG) System.out.println(this.position + "\t\tldc_w:"+constant); //$NON-NLS-1$
4856
		// Generate a ldc_w
4830
		// Generate a ldc_w
4857
		if (this.classFileOffset + 2 >= this.bCodeStream.length) {
4831
		if (this.classFileOffset + 2 >= this.bCodeStream.length) {
4858
			resizeByteArray();
4832
			resizeByteArray();
Lines 4861-4867 Link Here
4861
		this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc_w;
4835
		this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc_w;
4862
		writeUnsignedShort(index);
4836
		writeUnsignedShort(index);
4863
	} else {
4837
	} else {
4864
		if (DEBUG) System.out.println(this.position + "\t\tldc:"+constant); //$NON-NLS-1$
4865
		// Generate a ldc
4838
		// Generate a ldc
4866
		if (this.classFileOffset + 1 >= this.bCodeStream.length) {
4839
		if (this.classFileOffset + 1 >= this.bCodeStream.length) {
4867
			resizeByteArray();
4840
			resizeByteArray();
Lines 4871-4876 Link Here
4871
		this.bCodeStream[this.classFileOffset++] = (byte) index;
4844
		this.bCodeStream[this.classFileOffset++] = (byte) index;
4872
	}
4845
	}
4873
}
4846
}
4847
4874
public void ldc(String constant) {
4848
public void ldc(String constant) {
4875
	this.countLabels = 0;
4849
	this.countLabels = 0;
4876
	int currentCodeStreamPosition = this.position;
4850
	int currentCodeStreamPosition = this.position;
Lines 4969-4974 Link Here
4969
		invokeStringIntern();
4943
		invokeStringIntern();
4970
	}
4944
	}
4971
}
4945
}
4946
4972
public void ldc(TypeBinding typeBinding) {
4947
public void ldc(TypeBinding typeBinding) {
4973
	this.countLabels = 0;
4948
	this.countLabels = 0;
4974
	int index = this.constantPool.literalIndexForType(typeBinding);
4949
	int index = this.constantPool.literalIndexForType(typeBinding);
Lines 4976-4982 Link Here
4976
	if (this.stackDepth > this.stackMax)
4951
	if (this.stackDepth > this.stackMax)
4977
		this.stackMax = this.stackDepth;
4952
		this.stackMax = this.stackDepth;
4978
	if (index > 255) {
4953
	if (index > 255) {
4979
		if (DEBUG) System.out.println(this.position + "\t\tldc_w:"+ typeBinding); //$NON-NLS-1$
4980
		// Generate a ldc_w
4954
		// Generate a ldc_w
4981
		if (this.classFileOffset + 2 >= this.bCodeStream.length) {
4955
		if (this.classFileOffset + 2 >= this.bCodeStream.length) {
4982
			resizeByteArray();
4956
			resizeByteArray();
Lines 4985-4991 Link Here
4985
		this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc_w;
4959
		this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc_w;
4986
		writeUnsignedShort(index);
4960
		writeUnsignedShort(index);
4987
	} else {
4961
	} else {
4988
		if (DEBUG) System.out.println(this.position + "\t\tldw:"+ typeBinding); //$NON-NLS-1$
4989
		// Generate a ldc
4962
		// Generate a ldc
4990
		if (this.classFileOffset + 1 >= this.bCodeStream.length) {
4963
		if (this.classFileOffset + 1 >= this.bCodeStream.length) {
4991
			resizeByteArray();
4964
			resizeByteArray();
Lines 4995-5002 Link Here
4995
		this.bCodeStream[this.classFileOffset++] = (byte) index;
4968
		this.bCodeStream[this.classFileOffset++] = (byte) index;
4996
	}
4969
	}
4997
}
4970
}
4971
4998
public void ldc2_w(double constant) {
4972
public void ldc2_w(double constant) {
4999
	if (DEBUG) System.out.println(this.position + "\t\tldc2_w:"+constant); //$NON-NLS-1$
5000
	this.countLabels = 0;
4973
	this.countLabels = 0;
5001
	int index = this.constantPool.literalIndex(constant);
4974
	int index = this.constantPool.literalIndex(constant);
5002
	this.stackDepth += 2;
4975
	this.stackDepth += 2;
Lines 5010-5017 Link Here
5010
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc2_w;
4983
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc2_w;
5011
	writeUnsignedShort(index);
4984
	writeUnsignedShort(index);
5012
}
4985
}
4986
5013
public void ldc2_w(long constant) {
4987
public void ldc2_w(long constant) {
5014
	if (DEBUG) System.out.println(this.position + "\t\tldc2_w:"+constant); //$NON-NLS-1$
5015
	this.countLabels = 0;
4988
	this.countLabels = 0;
5016
	int index = this.constantPool.literalIndex(constant);
4989
	int index = this.constantPool.literalIndex(constant);
5017
	this.stackDepth += 2;
4990
	this.stackDepth += 2;
Lines 5025-5030 Link Here
5025
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc2_w;
4998
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldc2_w;
5026
	writeUnsignedShort(index);
4999
	writeUnsignedShort(index);
5027
}
5000
}
5001
5028
public void ldcForIndex(int index, char[] constant) {
5002
public void ldcForIndex(int index, char[] constant) {
5029
	this.stackDepth++;
5003
	this.stackDepth++;
5030
	if (this.stackDepth > this.stackMax) {
5004
	if (this.stackDepth > this.stackMax) {
Lines 5032-5038 Link Here
5032
	}
5006
	}
5033
	if (index > 255) {
5007
	if (index > 255) {
5034
		// Generate a ldc_w
5008
		// Generate a ldc_w
5035
		if (DEBUG) System.out.println(this.position + "\t\tldc_w:"+ new String(constant)); //$NON-NLS-1$
5036
		if (this.classFileOffset + 2 >= this.bCodeStream.length) {
5009
		if (this.classFileOffset + 2 >= this.bCodeStream.length) {
5037
			resizeByteArray();
5010
			resizeByteArray();
5038
		}
5011
		}
Lines 5041-5047 Link Here
5041
		writeUnsignedShort(index);
5014
		writeUnsignedShort(index);
5042
	} else {
5015
	} else {
5043
		// Generate a ldc
5016
		// Generate a ldc
5044
		if (DEBUG) System.out.println(this.position + "\t\tldc:"+ new String(constant)); //$NON-NLS-1$
5045
		if (this.classFileOffset + 1 >= this.bCodeStream.length) {
5017
		if (this.classFileOffset + 1 >= this.bCodeStream.length) {
5046
			resizeByteArray();
5018
			resizeByteArray();
5047
		}
5019
		}
Lines 5050-5057 Link Here
5050
		this.bCodeStream[this.classFileOffset++] = (byte) index;
5022
		this.bCodeStream[this.classFileOffset++] = (byte) index;
5051
	}
5023
	}
5052
}
5024
}
5025
5053
public void ldiv() {
5026
public void ldiv() {
5054
	if (DEBUG) System.out.println(this.position + "\t\tldiv"); //$NON-NLS-1$
5055
	this.countLabels = 0;
5027
	this.countLabels = 0;
5056
	this.stackDepth -= 2;
5028
	this.stackDepth -= 2;
5057
	if (this.classFileOffset >= this.bCodeStream.length) {
5029
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5060-5067 Link Here
5060
	this.position++;
5032
	this.position++;
5061
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldiv;
5033
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_ldiv;
5062
}
5034
}
5035
5063
public void lload(int iArg) {
5036
public void lload(int iArg) {
5064
	if (DEBUG) System.out.println(this.position + "\t\tlload:"+iArg); //$NON-NLS-1$
5065
	this.countLabels = 0;
5037
	this.countLabels = 0;
5066
	this.stackDepth += 2;
5038
	this.stackDepth += 2;
5067
	if (this.maxLocals <= iArg + 1) {
5039
	if (this.maxLocals <= iArg + 1) {
Lines 5086-5093 Link Here
5086
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
5058
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
5087
	}
5059
	}
5088
}
5060
}
5061
5089
public void lload_0() {
5062
public void lload_0() {
5090
	if (DEBUG) System.out.println(this.position + "\t\tlload_0"); //$NON-NLS-1$
5091
	this.countLabels = 0;
5063
	this.countLabels = 0;
5092
	this.stackDepth += 2;
5064
	this.stackDepth += 2;
5093
	if (this.maxLocals < 2) {
5065
	if (this.maxLocals < 2) {
Lines 5101-5108 Link Here
5101
	this.position++;
5073
	this.position++;
5102
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_0;
5074
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_0;
5103
}
5075
}
5076
5104
public void lload_1() {
5077
public void lload_1() {
5105
	if (DEBUG) System.out.println(this.position + "\t\tlload_1"); //$NON-NLS-1$
5106
	this.countLabels = 0;
5078
	this.countLabels = 0;
5107
	this.stackDepth += 2;
5079
	this.stackDepth += 2;
5108
	if (this.maxLocals < 3) {
5080
	if (this.maxLocals < 3) {
Lines 5116-5123 Link Here
5116
	this.position++;
5088
	this.position++;
5117
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_1;
5089
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_1;
5118
}
5090
}
5091
5119
public void lload_2() {
5092
public void lload_2() {
5120
	if (DEBUG) System.out.println(this.position + "\t\tlload_2"); //$NON-NLS-1$
5121
	this.countLabels = 0;
5093
	this.countLabels = 0;
5122
	this.stackDepth += 2;
5094
	this.stackDepth += 2;
5123
	if (this.maxLocals < 4) {
5095
	if (this.maxLocals < 4) {
Lines 5131-5138 Link Here
5131
	this.position++;
5103
	this.position++;
5132
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_2;
5104
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_2;
5133
}
5105
}
5106
5134
public void lload_3() {
5107
public void lload_3() {
5135
	if (DEBUG) System.out.println(this.position + "\t\tlload_3"); //$NON-NLS-1$
5136
	this.countLabels = 0;
5108
	this.countLabels = 0;
5137
	this.stackDepth += 2;
5109
	this.stackDepth += 2;
5138
	if (this.maxLocals < 5) {
5110
	if (this.maxLocals < 5) {
Lines 5146-5153 Link Here
5146
	this.position++;
5118
	this.position++;
5147
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_3;
5119
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lload_3;
5148
}
5120
}
5121
5149
public void lmul() {
5122
public void lmul() {
5150
	if (DEBUG) System.out.println(this.position + "\t\tlmul"); //$NON-NLS-1$
5151
	this.countLabels = 0;
5123
	this.countLabels = 0;
5152
	this.stackDepth -= 2;
5124
	this.stackDepth -= 2;
5153
	if (this.classFileOffset >= this.bCodeStream.length) {
5125
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5156-5163 Link Here
5156
	this.position++;
5128
	this.position++;
5157
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lmul;
5129
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lmul;
5158
}
5130
}
5131
5159
public void lneg() {
5132
public void lneg() {
5160
	if (DEBUG) System.out.println(this.position + "\t\tlneg"); //$NON-NLS-1$
5161
	this.countLabels = 0;
5133
	this.countLabels = 0;
5162
	if (this.classFileOffset >= this.bCodeStream.length) {
5134
	if (this.classFileOffset >= this.bCodeStream.length) {
5163
		resizeByteArray();
5135
		resizeByteArray();
Lines 5165-5173 Link Here
5165
	this.position++;
5137
	this.position++;
5166
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lneg;
5138
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lneg;
5167
}
5139
}
5140
5168
public final void load(LocalVariableBinding localBinding) {
5141
public final void load(LocalVariableBinding localBinding) {
5169
	load(localBinding.type, localBinding.resolvedPosition);
5142
	load(localBinding.type, localBinding.resolvedPosition);
5170
}
5143
}
5144
5171
public final void load(TypeBinding typeBinding, int resolvedPosition) {
5145
public final void load(TypeBinding typeBinding, int resolvedPosition) {
5172
	this.countLabels = 0;
5146
	this.countLabels = 0;
5173
	// Using dedicated int bytecode
5147
	// Using dedicated int bytecode
Lines 5270-5277 Link Here
5270
			}
5244
			}
5271
	}
5245
	}
5272
}
5246
}
5247
5273
public void lookupswitch(CaseLabel defaultLabel, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) {
5248
public void lookupswitch(CaseLabel defaultLabel, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) {
5274
	if (DEBUG) System.out.println(this.position + "\t\tlookupswitch"); //$NON-NLS-1$
5275
	this.countLabels = 0;
5249
	this.countLabels = 0;
5276
	this.stackDepth--;
5250
	this.stackDepth--;
5277
	int length = keys.length;
5251
	int length = keys.length;
Lines 5299-5306 Link Here
5299
		casesLabel[sortedIndexes[i]].branch();
5273
		casesLabel[sortedIndexes[i]].branch();
5300
	}
5274
	}
5301
}
5275
}
5276
5302
public void lor() {
5277
public void lor() {
5303
	if (DEBUG) System.out.println(this.position + "\t\tlor"); //$NON-NLS-1$
5304
	this.countLabels = 0;
5278
	this.countLabels = 0;
5305
	this.stackDepth -= 2;
5279
	this.stackDepth -= 2;
5306
	if (this.classFileOffset >= this.bCodeStream.length) {
5280
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5309-5316 Link Here
5309
	this.position++;
5283
	this.position++;
5310
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lor;
5284
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lor;
5311
}
5285
}
5286
5312
public void lrem() {
5287
public void lrem() {
5313
	if (DEBUG) System.out.println(this.position + "\t\tlrem"); //$NON-NLS-1$
5314
	this.countLabels = 0;
5288
	this.countLabels = 0;
5315
	this.stackDepth -= 2;
5289
	this.stackDepth -= 2;
5316
	if (this.classFileOffset >= this.bCodeStream.length) {
5290
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5319-5326 Link Here
5319
	this.position++;
5293
	this.position++;
5320
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lrem;
5294
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lrem;
5321
}
5295
}
5296
5322
public void lreturn() {
5297
public void lreturn() {
5323
	if (DEBUG) System.out.println(this.position + "\t\tlreturn"); //$NON-NLS-1$
5324
	this.countLabels = 0;
5298
	this.countLabels = 0;
5325
	this.stackDepth -= 2;
5299
	this.stackDepth -= 2;
5326
	// the stackDepth should be equal to 0
5300
	// the stackDepth should be equal to 0
Lines 5331-5338 Link Here
5331
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lreturn;
5305
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lreturn;
5332
	this.lastAbruptCompletion = this.position;
5306
	this.lastAbruptCompletion = this.position;
5333
}
5307
}
5308
5334
public void lshl() {
5309
public void lshl() {
5335
	if (DEBUG) System.out.println(this.position + "\t\tlshl"); //$NON-NLS-1$
5336
	this.countLabels = 0;
5310
	this.countLabels = 0;
5337
	this.stackDepth--;
5311
	this.stackDepth--;
5338
	if (this.classFileOffset >= this.bCodeStream.length) {
5312
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5341-5348 Link Here
5341
	this.position++;
5315
	this.position++;
5342
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lshl;
5316
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lshl;
5343
}
5317
}
5318
5344
public void lshr() {
5319
public void lshr() {
5345
	if (DEBUG) System.out.println(this.position + "\t\tlshr"); //$NON-NLS-1$
5346
	this.countLabels = 0;
5320
	this.countLabels = 0;
5347
	this.stackDepth--;
5321
	this.stackDepth--;
5348
	if (this.classFileOffset >= this.bCodeStream.length) {
5322
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5351-5358 Link Here
5351
	this.position++;
5325
	this.position++;
5352
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lshr;
5326
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lshr;
5353
}
5327
}
5328
5354
public void lstore(int iArg) {
5329
public void lstore(int iArg) {
5355
	if (DEBUG) System.out.println(this.position + "\t\tlstore:"+iArg); //$NON-NLS-1$
5356
	this.countLabels = 0;
5330
	this.countLabels = 0;
5357
	this.stackDepth -= 2;
5331
	this.stackDepth -= 2;
5358
	if (this.maxLocals <= iArg + 1) {
5332
	if (this.maxLocals <= iArg + 1) {
Lines 5375-5382 Link Here
5375
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
5349
		this.bCodeStream[this.classFileOffset++] = (byte) iArg;
5376
	}
5350
	}
5377
}
5351
}
5352
5378
public void lstore_0() {
5353
public void lstore_0() {
5379
	if (DEBUG) System.out.println(this.position + "\t\tlstore_0"); //$NON-NLS-1$
5380
	this.countLabels = 0;
5354
	this.countLabels = 0;
5381
	this.stackDepth -= 2;
5355
	this.stackDepth -= 2;
5382
	if (this.maxLocals < 2) {
5356
	if (this.maxLocals < 2) {
Lines 5388-5395 Link Here
5388
	this.position++;
5362
	this.position++;
5389
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_0;
5363
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_0;
5390
}
5364
}
5365
5391
public void lstore_1() {
5366
public void lstore_1() {
5392
	if (DEBUG) System.out.println(this.position + "\t\tlstore_1"); //$NON-NLS-1$
5393
	this.countLabels = 0;
5367
	this.countLabels = 0;
5394
	this.stackDepth -= 2;
5368
	this.stackDepth -= 2;
5395
	if (this.maxLocals < 3) {
5369
	if (this.maxLocals < 3) {
Lines 5401-5408 Link Here
5401
	this.position++;
5375
	this.position++;
5402
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_1;
5376
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_1;
5403
}
5377
}
5378
5404
public void lstore_2() {
5379
public void lstore_2() {
5405
	if (DEBUG) System.out.println(this.position + "\t\tlstore_2"); //$NON-NLS-1$
5406
	this.countLabels = 0;
5380
	this.countLabels = 0;
5407
	this.stackDepth -= 2;
5381
	this.stackDepth -= 2;
5408
	if (this.maxLocals < 4) {
5382
	if (this.maxLocals < 4) {
Lines 5414-5421 Link Here
5414
	this.position++;
5388
	this.position++;
5415
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_2;
5389
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_2;
5416
}
5390
}
5391
5417
public void lstore_3() {
5392
public void lstore_3() {
5418
	if (DEBUG) System.out.println(this.position + "\t\tlstore_3"); //$NON-NLS-1$
5419
	this.countLabels = 0;
5393
	this.countLabels = 0;
5420
	this.stackDepth -= 2;
5394
	this.stackDepth -= 2;
5421
	if (this.maxLocals < 5) {
5395
	if (this.maxLocals < 5) {
Lines 5427-5434 Link Here
5427
	this.position++;
5401
	this.position++;
5428
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_3;
5402
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lstore_3;
5429
}
5403
}
5404
5430
public void lsub() {
5405
public void lsub() {
5431
	if (DEBUG) System.out.println(this.position + "\t\tlsub"); //$NON-NLS-1$
5432
	this.countLabels = 0;
5406
	this.countLabels = 0;
5433
	this.stackDepth -= 2;
5407
	this.stackDepth -= 2;
5434
	if (this.classFileOffset >= this.bCodeStream.length) {
5408
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5437-5444 Link Here
5437
	this.position++;
5411
	this.position++;
5438
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lsub;
5412
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lsub;
5439
}
5413
}
5414
5440
public void lushr() {
5415
public void lushr() {
5441
	if (DEBUG) System.out.println(this.position + "\t\tlushr"); //$NON-NLS-1$
5442
	this.countLabels = 0;
5416
	this.countLabels = 0;
5443
	this.stackDepth--;
5417
	this.stackDepth--;
5444
	if (this.classFileOffset >= this.bCodeStream.length) {
5418
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5447-5454 Link Here
5447
	this.position++;
5421
	this.position++;
5448
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lushr;
5422
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lushr;
5449
}
5423
}
5424
5450
public void lxor() {
5425
public void lxor() {
5451
	if (DEBUG) System.out.println(this.position + "\t\tlxor"); //$NON-NLS-1$
5452
	this.countLabels = 0;
5426
	this.countLabels = 0;
5453
	this.stackDepth -= 2;
5427
	this.stackDepth -= 2;
5454
	if (this.classFileOffset >= this.bCodeStream.length) {
5428
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5457-5464 Link Here
5457
	this.position++;
5431
	this.position++;
5458
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lxor;
5432
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_lxor;
5459
}
5433
}
5434
5460
public void monitorenter() {
5435
public void monitorenter() {
5461
	if (DEBUG) System.out.println(this.position + "\t\tmonitorenter"); //$NON-NLS-1$
5462
	this.countLabels = 0;
5436
	this.countLabels = 0;
5463
	this.stackDepth--;
5437
	this.stackDepth--;
5464
	if (this.classFileOffset >= this.bCodeStream.length) {
5438
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5467-5474 Link Here
5467
	this.position++;
5441
	this.position++;
5468
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_monitorenter;
5442
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_monitorenter;
5469
}
5443
}
5444
5470
public void monitorexit() {
5445
public void monitorexit() {
5471
	if (DEBUG) System.out.println(this.position + "\t\tmonitorexit"); //$NON-NLS-1$
5472
	this.countLabels = 0;
5446
	this.countLabels = 0;
5473
	this.stackDepth--;
5447
	this.stackDepth--;
5474
	if (this.classFileOffset >= this.bCodeStream.length) {
5448
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5477-5484 Link Here
5477
	this.position++;
5451
	this.position++;
5478
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_monitorexit;
5452
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_monitorexit;
5479
}
5453
}
5454
5480
public void multianewarray(TypeBinding typeBinding, int dimensions) {
5455
public void multianewarray(TypeBinding typeBinding, int dimensions) {
5481
	if (DEBUG) System.out.println(this.position + "\t\tmultinewarray:"+typeBinding+","+dimensions); //$NON-NLS-1$ //$NON-NLS-2$
5482
	this.countLabels = 0;
5456
	this.countLabels = 0;
5483
	this.stackDepth += (1 - dimensions);
5457
	this.stackDepth += (1 - dimensions);
5484
	if (this.classFileOffset + 3 >= this.bCodeStream.length) {
5458
	if (this.classFileOffset + 3 >= this.bCodeStream.length) {
Lines 5489-5497 Link Here
5489
	writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
5463
	writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
5490
	this.bCodeStream[this.classFileOffset++] = (byte) dimensions;
5464
	this.bCodeStream[this.classFileOffset++] = (byte) dimensions;
5491
}
5465
}
5466
5492
// We didn't call it new, because there is a conflit with the new keyword
5467
// We didn't call it new, because there is a conflit with the new keyword
5493
public void new_(TypeBinding typeBinding) {
5468
public void new_(TypeBinding typeBinding) {
5494
	if (DEBUG) System.out.println(this.position + "\t\tnew:"+typeBinding.debugName()); //$NON-NLS-1$
5495
	this.countLabels = 0;
5469
	this.countLabels = 0;
5496
	this.stackDepth++;
5470
	this.stackDepth++;
5497
	if (this.stackDepth > this.stackMax)
5471
	if (this.stackDepth > this.stackMax)
Lines 5503-5510 Link Here
5503
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new;
5477
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new;
5504
	writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
5478
	writeUnsignedShort(this.constantPool.literalIndexForType(typeBinding));
5505
}
5479
}
5480
5506
public void newarray(int array_Type) {
5481
public void newarray(int array_Type) {
5507
	if (DEBUG) System.out.println(this.position + "\t\tnewarray:"+array_Type); //$NON-NLS-1$
5508
	this.countLabels = 0;
5482
	this.countLabels = 0;
5509
	if (this.classFileOffset + 1 >= this.bCodeStream.length) {
5483
	if (this.classFileOffset + 1 >= this.bCodeStream.length) {
5510
		resizeByteArray();
5484
		resizeByteArray();
Lines 5513-5518 Link Here
5513
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_newarray;
5487
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_newarray;
5514
	this.bCodeStream[this.classFileOffset++] = (byte) array_Type;
5488
	this.bCodeStream[this.classFileOffset++] = (byte) array_Type;
5515
}
5489
}
5490
5516
public void newArray(ArrayBinding arrayBinding) {
5491
public void newArray(ArrayBinding arrayBinding) {
5517
	TypeBinding component = arrayBinding.elementsType();
5492
	TypeBinding component = arrayBinding.elementsType();
5518
	switch (component.id) {
5493
	switch (component.id) {
Lines 5544-5552 Link Here
5544
			anewarray(component);
5519
			anewarray(component);
5545
	}
5520
	}
5546
}
5521
}
5522
5547
public void newJavaLangAssertionError() {
5523
public void newJavaLangAssertionError() {
5548
	// new: java.lang.AssertionError
5524
	// new: java.lang.AssertionError
5549
	if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.AssertionError"); //$NON-NLS-1$
5550
	this.countLabels = 0;
5525
	this.countLabels = 0;
5551
	this.stackDepth++;
5526
	this.stackDepth++;
5552
	if (this.stackDepth > this.stackMax)
5527
	if (this.stackDepth > this.stackMax)
Lines 5558-5566 Link Here
5558
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new;
5533
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new;
5559
	writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangAssertionErrorConstantPoolName));
5534
	writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangAssertionErrorConstantPoolName));
5560
}
5535
}
5536
5561
public void newJavaLangError() {
5537
public void newJavaLangError() {
5562
	// new: java.lang.Error
5538
	// new: java.lang.Error
5563
	if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Error"); //$NON-NLS-1$
5564
	this.countLabels = 0;
5539
	this.countLabels = 0;
5565
	this.stackDepth++;
5540
	this.stackDepth++;
5566
	if (this.stackDepth > this.stackMax)
5541
	if (this.stackDepth > this.stackMax)
Lines 5572-5580 Link Here
5572
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new;
5547
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new;
5573
	writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangErrorConstantPoolName));
5548
	writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangErrorConstantPoolName));
5574
}
5549
}
5550
5575
public void newNoClassDefFoundError() {
5551
public void newNoClassDefFoundError() {
5576
	// new: java.lang.NoClassDefFoundError
5552
	// new: java.lang.NoClassDefFoundError
5577
	if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.NoClassDefFoundError"); //$NON-NLS-1$
5578
	this.countLabels = 0;
5553
	this.countLabels = 0;
5579
	this.stackDepth++;
5554
	this.stackDepth++;
5580
	if (this.stackDepth > this.stackMax)
5555
	if (this.stackDepth > this.stackMax)
Lines 5586-5601 Link Here
5586
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new;
5561
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new;
5587
	writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangNoClassDefFoundErrorConstantPoolName));
5562
	writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangNoClassDefFoundErrorConstantPoolName));
5588
}
5563
}
5564
5589
public void newStringContatenation() {
5565
public void newStringContatenation() {
5590
	// new: java.lang.StringBuffer
5566
	// new: java.lang.StringBuffer
5591
	// new: java.lang.StringBuilder
5567
	// new: java.lang.StringBuilder
5592
	if (DEBUG) {
5593
		if (this.targetLevel >= ClassFileConstants.JDK1_5) {
5594
			System.out.println(this.position + "\t\tnew: java.lang.StringBuilder"); //$NON-NLS-1$
5595
		} else {
5596
			System.out.println(this.position + "\t\tnew: java.lang.StringBuffer"); //$NON-NLS-1$
5597
		}
5598
	}
5599
	this.countLabels = 0;
5568
	this.countLabels = 0;
5600
	this.stackDepth++;
5569
	this.stackDepth++;
5601
	if (this.stackDepth > this.stackMax) {
5570
	if (this.stackDepth > this.stackMax) {
Lines 5612-5617 Link Here
5612
		writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangStringBufferConstantPoolName));
5581
		writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangStringBufferConstantPoolName));
5613
	}
5582
	}
5614
}
5583
}
5584
5615
public void newWrapperFor(int typeID) {
5585
public void newWrapperFor(int typeID) {
5616
	this.countLabels = 0;
5586
	this.countLabels = 0;
5617
	this.stackDepth++;
5587
	this.stackDepth++;
Lines 5624-5667 Link Here
5624
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new;
5594
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_new;
5625
	switch (typeID) {
5595
	switch (typeID) {
5626
		case TypeIds.T_int : // new: java.lang.Integer
5596
		case TypeIds.T_int : // new: java.lang.Integer
5627
			if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Integer"); //$NON-NLS-1$
5628
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangIntegerConstantPoolName));
5597
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangIntegerConstantPoolName));
5629
			break;
5598
			break;
5630
		case TypeIds.T_boolean : // new: java.lang.Boolean
5599
		case TypeIds.T_boolean : // new: java.lang.Boolean
5631
			if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Boolean"); //$NON-NLS-1$
5632
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangBooleanConstantPoolName));
5600
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangBooleanConstantPoolName));
5633
			break;
5601
			break;
5634
		case TypeIds.T_byte : // new: java.lang.Byte
5602
		case TypeIds.T_byte : // new: java.lang.Byte
5635
			if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Byte"); //$NON-NLS-1$
5636
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangByteConstantPoolName));
5603
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangByteConstantPoolName));
5637
			break;
5604
			break;
5638
		case TypeIds.T_char : // new: java.lang.Character
5605
		case TypeIds.T_char : // new: java.lang.Character
5639
			if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Character"); //$NON-NLS-1$
5640
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangCharacterConstantPoolName));
5606
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangCharacterConstantPoolName));
5641
			break;
5607
			break;
5642
		case TypeIds.T_float : // new: java.lang.Float
5608
		case TypeIds.T_float : // new: java.lang.Float
5643
			if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Float"); //$NON-NLS-1$
5644
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangFloatConstantPoolName));
5609
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangFloatConstantPoolName));
5645
			break;
5610
			break;
5646
		case TypeIds.T_double : // new: java.lang.Double
5611
		case TypeIds.T_double : // new: java.lang.Double
5647
			if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Double"); //$NON-NLS-1$
5648
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangDoubleConstantPoolName));
5612
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangDoubleConstantPoolName));
5649
			break;
5613
			break;
5650
		case TypeIds.T_short : // new: java.lang.Short
5614
		case TypeIds.T_short : // new: java.lang.Short
5651
			if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Short"); //$NON-NLS-1$
5652
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangShortConstantPoolName));
5615
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangShortConstantPoolName));
5653
			break;
5616
			break;
5654
		case TypeIds.T_long : // new: java.lang.Long
5617
		case TypeIds.T_long : // new: java.lang.Long
5655
			if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Long"); //$NON-NLS-1$
5656
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangLongConstantPoolName));
5618
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangLongConstantPoolName));
5657
			break;
5619
			break;
5658
		case TypeIds.T_void : // new: java.lang.Void
5620
		case TypeIds.T_void : // new: java.lang.Void
5659
			if (DEBUG) System.out.println(this.position + "\t\tnew: java.lang.Void"); //$NON-NLS-1$
5660
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangVoidConstantPoolName));
5621
			writeUnsignedShort(this.constantPool.literalIndexForType(ConstantPool.JavaLangVoidConstantPoolName));
5661
	}
5622
	}
5662
}
5623
}
5624
5663
public void nop() {
5625
public void nop() {
5664
	if (DEBUG) System.out.println(this.position + "\t\tnop"); //$NON-NLS-1$
5665
	this.countLabels = 0;
5626
	this.countLabels = 0;
5666
	if (this.classFileOffset >= this.bCodeStream.length) {
5627
	if (this.classFileOffset >= this.bCodeStream.length) {
5667
		resizeByteArray();
5628
		resizeByteArray();
Lines 5669-5674 Link Here
5669
	this.position++;
5630
	this.position++;
5670
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_nop;
5631
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_nop;
5671
}
5632
}
5633
5672
public void optimizeBranch(int oldPosition, BranchLabel lbl) {
5634
public void optimizeBranch(int oldPosition, BranchLabel lbl) {
5673
	for (int i = 0; i < this.countLabels; i++) {
5635
	for (int i = 0; i < this.countLabels; i++) {
5674
		BranchLabel label = this.labels[i];
5636
		BranchLabel label = this.labels[i];
Lines 5691-5698 Link Here
5691
		}
5653
		}
5692
	}
5654
	}
5693
}
5655
}
5656
5694
public void pop() {
5657
public void pop() {
5695
	if (DEBUG) System.out.println(this.position + "\t\tpop"); //$NON-NLS-1$
5696
	this.countLabels = 0;
5658
	this.countLabels = 0;
5697
	this.stackDepth--;
5659
	this.stackDepth--;
5698
	if (this.classFileOffset >= this.bCodeStream.length) {
5660
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5701-5708 Link Here
5701
	this.position++;
5663
	this.position++;
5702
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_pop;
5664
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_pop;
5703
}
5665
}
5666
5704
public void pop2() {
5667
public void pop2() {
5705
	if (DEBUG) System.out.println(this.position + "\t\tpop2"); //$NON-NLS-1$
5706
	this.countLabels = 0;
5668
	this.countLabels = 0;
5707
	this.stackDepth -= 2;
5669
	this.stackDepth -= 2;
5708
	if (this.classFileOffset >= this.bCodeStream.length) {
5670
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 5711-5727 Link Here
5711
	this.position++;
5673
	this.position++;
5712
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_pop2;
5674
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_pop2;
5713
}
5675
}
5714
public void pushOnStack(TypeBinding binding) {
5676
5715
	if (++this.stackDepth > this.stackMax)
5716
		this.stackMax = this.stackDepth;
5717
}
5718
public void pushExceptionOnStack(TypeBinding binding) {
5677
public void pushExceptionOnStack(TypeBinding binding) {
5719
	this.stackDepth = 1;
5678
	this.stackDepth = 1;
5720
	if (this.stackDepth > this.stackMax)
5679
	if (this.stackDepth > this.stackMax)
5721
		this.stackMax = this.stackDepth;
5680
		this.stackMax = this.stackDepth;
5722
}
5681
}
5682
5683
public void pushOnStack(TypeBinding binding) {
5684
	if (++this.stackDepth > this.stackMax)
5685
		this.stackMax = this.stackDepth;
5686
}
5687
5723
public void putfield(FieldBinding fieldBinding) {
5688
public void putfield(FieldBinding fieldBinding) {
5724
	if (DEBUG) System.out.println(this.position + "\t\tputfield:"+fieldBinding); //$NON-NLS-1$
5725
	int returnTypeSize = 1;
5689
	int returnTypeSize = 1;
5726
	if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) {
5690
	if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) {
5727
		returnTypeSize = 2;
5691
		returnTypeSize = 2;
Lines 5733-5740 Link Here
5733
			fieldBinding.name,
5697
			fieldBinding.name,
5734
			fieldBinding.type);
5698
			fieldBinding.type);
5735
}
5699
}
5700
5736
public void putstatic(FieldBinding fieldBinding) {
5701
public void putstatic(FieldBinding fieldBinding) {
5737
	if (DEBUG) System.out.println(this.position + "\t\tputstatic:"+fieldBinding); //$NON-NLS-1$
5738
	int returnTypeSize = 1;
5702
	int returnTypeSize = 1;
5739
	if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) {
5703
	if ((fieldBinding.type.id == TypeIds.T_double) || (fieldBinding.type.id == TypeIds.T_long)) {
5740
		returnTypeSize = 2;
5704
		returnTypeSize = 2;
Lines 5746-5751 Link Here
5746
			fieldBinding.name,
5710
			fieldBinding.name,
5747
			fieldBinding.type);
5711
			fieldBinding.type);
5748
}
5712
}
5713
5749
public void record(LocalVariableBinding local) {
5714
public void record(LocalVariableBinding local) {
5750
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
5715
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
5751
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
5716
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
Lines 5763-5779 Link Here
5763
public void recordExpressionType(TypeBinding typeBinding) {
5728
public void recordExpressionType(TypeBinding typeBinding) {
5764
	// nothing to do
5729
	// nothing to do
5765
}
5730
}
5731
5766
public void recordPositionsFrom(int startPC, int sourcePos) {
5732
public void recordPositionsFrom(int startPC, int sourcePos) {
5767
	this.recordPositionsFrom(startPC, sourcePos, false);
5733
	this.recordPositionsFrom(startPC, sourcePos, false);
5768
}
5734
}
5769
public void recordPositionsFrom(int startPC, int sourcePos, boolean widen) {
5770
5735
5736
public void recordPositionsFrom(int startPC, int sourcePos, boolean widen) {
5771
	/* Record positions in the table, only if nothing has
5737
	/* Record positions in the table, only if nothing has
5772
	 * already been recorded. Since we output them on the way
5738
	 * already been recorded. Since we output them on the way
5773
	 * up (children first for more specific info)
5739
	 * up (children first for more specific info)
5774
	 * The pcToSourceMap table is always sorted.
5740
	 * The pcToSourceMap table is always sorted.
5775
	 */
5741
	 */
5776
5777
	if ((this.generateAttributes & ClassFileConstants.ATTR_LINES) == 0
5742
	if ((this.generateAttributes & ClassFileConstants.ATTR_LINES) == 0
5778
			|| sourcePos == 0
5743
			|| sourcePos == 0
5779
			|| (startPC == this.position && !widen))
5744
			|| (startPC == this.position && !widen))
Lines 6099-6104 Link Here
6099
		this.lastEntryPC = this.position;
6064
		this.lastEntryPC = this.position;
6100
	}
6065
	}
6101
}
6066
}
6067
6102
/**
6068
/**
6103
 * @param anExceptionLabel org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel
6069
 * @param anExceptionLabel org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel
6104
 */
6070
 */
Lines 6111-6116 Link Here
6111
	// no need to resize. So just add the new exception label
6077
	// no need to resize. So just add the new exception label
6112
	this.exceptionLabels[this.exceptionLabelsCounter++] = anExceptionLabel;
6078
	this.exceptionLabels[this.exceptionLabelsCounter++] = anExceptionLabel;
6113
}
6079
}
6080
6114
public void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
6081
public void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
6115
	// given some flow info, make sure we did not loose some variables initialization
6082
	// given some flow info, make sure we did not loose some variables initialization
6116
	// if this happens, then we must update their pc entries to reflect it in debug attributes
6083
	// if this happens, then we must update their pc entries to reflect it in debug attributes
Lines 6125-6130 Link Here
6125
		}
6092
		}
6126
	}
6093
	}
6127
}
6094
}
6095
6128
/**
6096
/**
6129
 * Remove all entries in pcToSourceMap table that are beyond this.position
6097
 * Remove all entries in pcToSourceMap table that are beyond this.position
6130
 */
6098
 */
Lines 6148-6153 Link Here
6148
		}
6116
		}
6149
	}
6117
	}
6150
}
6118
}
6119
6151
/**
6120
/**
6152
 * @param referenceMethod org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
6121
 * @param referenceMethod org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
6153
 * @param targetClassFile org.eclipse.jdt.internal.compiler.codegen.ClassFile
6122
 * @param targetClassFile org.eclipse.jdt.internal.compiler.codegen.ClassFile
Lines 6180-6185 Link Here
6180
	this.preserveUnusedLocals = referenceMethod.scope.compilerOptions().preserveAllLocalVariables;
6149
	this.preserveUnusedLocals = referenceMethod.scope.compilerOptions().preserveAllLocalVariables;
6181
	initializeMaxLocals(referenceMethod.binding);
6150
	initializeMaxLocals(referenceMethod.binding);
6182
}
6151
}
6152
6183
public void reset(ClassFile givenClassFile) {
6153
public void reset(ClassFile givenClassFile) {
6184
	this.targetLevel = givenClassFile.targetJDK;
6154
	this.targetLevel = givenClassFile.targetJDK;
6185
	int produceAttributes = givenClassFile.produceAttributes;
6155
	int produceAttributes = givenClassFile.produceAttributes;
Lines 6190-6195 Link Here
6190
		this.lineSeparatorPositions = null;
6160
		this.lineSeparatorPositions = null;
6191
	}
6161
	}
6192
}
6162
}
6163
6193
/**
6164
/**
6194
 * @param targetClassFile The given classfile to reset the code stream
6165
 * @param targetClassFile The given classfile to reset the code stream
6195
 */
6166
 */
Lines 6197-6202 Link Here
6197
	init(targetClassFile);
6168
	init(targetClassFile);
6198
	initializeMaxLocals(null);
6169
	initializeMaxLocals(null);
6199
}
6170
}
6171
6172
public void resetInWideMode() {
6173
	this.wideMode = true;
6174
}
6175
6200
private final void resizeByteArray() {
6176
private final void resizeByteArray() {
6201
	int length = this.bCodeStream.length;
6177
	int length = this.bCodeStream.length;
6202
	int requiredSize = length + length;
6178
	int requiredSize = length + length;
Lines 6206-6213 Link Here
6206
	}
6182
	}
6207
	System.arraycopy(this.bCodeStream, 0, this.bCodeStream = new byte[requiredSize], 0, length);
6183
	System.arraycopy(this.bCodeStream, 0, this.bCodeStream = new byte[requiredSize], 0, length);
6208
}
6184
}
6185
6209
final public void ret(int index) {
6186
final public void ret(int index) {
6210
	if (DEBUG) System.out.println(this.position + "\t\tret:"+index); //$NON-NLS-1$
6211
	this.countLabels = 0;
6187
	this.countLabels = 0;
6212
	if (index > 255) { // Widen
6188
	if (index > 255) { // Widen
6213
		if (this.classFileOffset + 3 >= this.bCodeStream.length) {
6189
		if (this.classFileOffset + 3 >= this.bCodeStream.length) {
Lines 6226-6233 Link Here
6226
		this.bCodeStream[this.classFileOffset++] = (byte) index;
6202
		this.bCodeStream[this.classFileOffset++] = (byte) index;
6227
	}
6203
	}
6228
}
6204
}
6205
6229
public void return_() {
6206
public void return_() {
6230
	if (DEBUG) System.out.println(this.position + "\t\treturn"); //$NON-NLS-1$
6231
	this.countLabels = 0;
6207
	this.countLabels = 0;
6232
	// the stackDepth should be equal to 0
6208
	// the stackDepth should be equal to 0
6233
	if (this.classFileOffset >= this.bCodeStream.length) {
6209
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 6237-6244 Link Here
6237
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_return;
6213
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_return;
6238
	this.lastAbruptCompletion = this.position;
6214
	this.lastAbruptCompletion = this.position;
6239
}
6215
}
6216
6240
public void saload() {
6217
public void saload() {
6241
	if (DEBUG) System.out.println(this.position + "\t\tsaload"); //$NON-NLS-1$
6242
	this.countLabels = 0;
6218
	this.countLabels = 0;
6243
	this.stackDepth--;
6219
	this.stackDepth--;
6244
	if (this.classFileOffset >= this.bCodeStream.length) {
6220
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 6247-6254 Link Here
6247
	this.position++;
6223
	this.position++;
6248
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_saload;
6224
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_saload;
6249
}
6225
}
6226
6250
public void sastore() {
6227
public void sastore() {
6251
	if (DEBUG) System.out.println(this.position + "\t\tsastore"); //$NON-NLS-1$
6252
	this.countLabels = 0;
6228
	this.countLabels = 0;
6253
	this.stackDepth -= 3;
6229
	this.stackDepth -= 3;
6254
	if (this.classFileOffset >= this.bCodeStream.length) {
6230
	if (this.classFileOffset >= this.bCodeStream.length) {
Lines 6257-6262 Link Here
6257
	this.position++;
6233
	this.position++;
6258
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_sastore;
6234
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_sastore;
6259
}
6235
}
6236
6260
/**
6237
/**
6261
 * @param operatorConstant int
6238
 * @param operatorConstant int
6262
 * @param type_ID int
6239
 * @param type_ID int
Lines 6380-6386 Link Here
6380
}
6357
}
6381
6358
6382
public void sipush(int s) {
6359
public void sipush(int s) {
6383
	if (DEBUG) System.out.println(this.position + "\t\tsipush:"+s); //$NON-NLS-1$
6384
	this.countLabels = 0;
6360
	this.countLabels = 0;
6385
	this.stackDepth++;
6361
	this.stackDepth++;
6386
	if (this.stackDepth > this.stackMax)
6362
	if (this.stackDepth > this.stackMax)
Lines 6392-6397 Link Here
6392
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_sipush;
6368
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_sipush;
6393
	writeSignedShort(s);
6369
	writeSignedShort(s);
6394
}
6370
}
6371
6395
public void store(LocalVariableBinding localBinding, boolean valueRequired) {
6372
public void store(LocalVariableBinding localBinding, boolean valueRequired) {
6396
	int localPosition = localBinding.resolvedPosition;
6373
	int localPosition = localBinding.resolvedPosition;
6397
	// Using dedicated int bytecode
6374
	// Using dedicated int bytecode
Lines 6505-6512 Link Here
6505
			}
6482
			}
6506
	}
6483
	}
6507
}
6484
}
6485
6508
public void swap() {
6486
public void swap() {
6509
	if (DEBUG) System.out.println(this.position + "\t\tswap"); //$NON-NLS-1$
6510
	this.countLabels = 0;
6487
	this.countLabels = 0;
6511
	if (this.classFileOffset >= this.bCodeStream.length) {
6488
	if (this.classFileOffset >= this.bCodeStream.length) {
6512
		resizeByteArray();
6489
		resizeByteArray();
Lines 6514-6521 Link Here
6514
	this.position++;
6491
	this.position++;
6515
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_swap;
6492
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_swap;
6516
}
6493
}
6494
6517
public void tableswitch(CaseLabel defaultLabel, int low, int high, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) {
6495
public void tableswitch(CaseLabel defaultLabel, int low, int high, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) {
6518
	if (DEBUG) System.out.println(this.position + "\t\ttableswitch"); //$NON-NLS-1$
6519
	this.countLabels = 0;
6496
	this.countLabels = 0;
6520
	this.stackDepth--;
6497
	this.stackDepth--;
6521
	int length = casesLabel.length;
6498
	int length = casesLabel.length;
Lines 6555-6564 Link Here
6555
		i++;
6532
		i++;
6556
	}
6533
	}
6557
}
6534
}
6535
6558
public void throwAnyException(LocalVariableBinding anyExceptionVariable) {
6536
public void throwAnyException(LocalVariableBinding anyExceptionVariable) {
6559
	this.load(anyExceptionVariable);
6537
	this.load(anyExceptionVariable);
6560
	athrow();
6538
	athrow();
6561
}
6539
}
6540
6562
public String toString() {
6541
public String toString() {
6563
	StringBuffer buffer = new StringBuffer("( position:"); //$NON-NLS-1$
6542
	StringBuffer buffer = new StringBuffer("( position:"); //$NON-NLS-1$
6564
	buffer.append(this.position);
6543
	buffer.append(this.position);
Lines 6571-6576 Link Here
6571
	buffer.append(")"); //$NON-NLS-1$
6550
	buffer.append(")"); //$NON-NLS-1$
6572
	return buffer.toString();
6551
	return buffer.toString();
6573
}
6552
}
6553
6574
/**
6554
/**
6575
 * Note: it will walk the locals table and extend the end range for all matching ones, no matter if
6555
 * Note: it will walk the locals table and extend the end range for all matching ones, no matter if
6576
 * visible or not.
6556
 * visible or not.
Lines 6609-6614 Link Here
6609
		}
6589
		}
6610
	}
6590
	}
6611
}
6591
}
6592
6612
protected void writePosition(BranchLabel label) {
6593
protected void writePosition(BranchLabel label) {
6613
	int offset = label.position - this.position + 1;
6594
	int offset = label.position - this.position + 1;
6614
	if (Math.abs(offset) > 0x7FFF && !this.wideMode) {
6595
	if (Math.abs(offset) > 0x7FFF && !this.wideMode) {
Lines 6620-6625 Link Here
6620
		this.writePosition(label, forwardRefs[i]);
6601
		this.writePosition(label, forwardRefs[i]);
6621
	}
6602
	}
6622
}
6603
}
6604
6623
protected void writePosition(BranchLabel label, int forwardReference) {
6605
protected void writePosition(BranchLabel label, int forwardReference) {
6624
	final int offset = label.position - forwardReference + 1;
6606
	final int offset = label.position - forwardReference + 1;
6625
	if (Math.abs(offset) > 0x7FFF && !this.wideMode) {
6607
	if (Math.abs(offset) > 0x7FFF && !this.wideMode) {
Lines 6635-6640 Link Here
6635
		this.writeSignedShort(forwardReference, offset);
6617
		this.writeSignedShort(forwardReference, offset);
6636
	}
6618
	}
6637
}
6619
}
6620
6638
/**
6621
/**
6639
 * Write a signed 16 bits value into the byte array
6622
 * Write a signed 16 bits value into the byte array
6640
 * @param value the signed short
6623
 * @param value the signed short
Lines 6648-6653 Link Here
6648
	this.bCodeStream[this.classFileOffset++] = (byte) (value >> 8);
6631
	this.bCodeStream[this.classFileOffset++] = (byte) (value >> 8);
6649
	this.bCodeStream[this.classFileOffset++] = (byte) value;
6632
	this.bCodeStream[this.classFileOffset++] = (byte) value;
6650
}
6633
}
6634
6651
private final void writeSignedShort(int pos, int value) {
6635
private final void writeSignedShort(int pos, int value) {
6652
	int currentOffset = this.startingClassFileOffset + pos;
6636
	int currentOffset = this.startingClassFileOffset + pos;
6653
	if (currentOffset + 1 >= this.bCodeStream.length) {
6637
	if (currentOffset + 1 >= this.bCodeStream.length) {
Lines 6656-6661 Link Here
6656
	this.bCodeStream[currentOffset] = (byte) (value >> 8);
6640
	this.bCodeStream[currentOffset] = (byte) (value >> 8);
6657
	this.bCodeStream[currentOffset + 1] = (byte) value;
6641
	this.bCodeStream[currentOffset + 1] = (byte) value;
6658
}
6642
}
6643
6659
protected final void writeSignedWord(int value) {
6644
protected final void writeSignedWord(int value) {
6660
	// we keep the resize in here because it is used outside the code stream
6645
	// we keep the resize in here because it is used outside the code stream
6661
	if (this.classFileOffset + 3 >= this.bCodeStream.length) {
6646
	if (this.classFileOffset + 3 >= this.bCodeStream.length) {
Lines 6667-6672 Link Here
6667
	this.bCodeStream[this.classFileOffset++] = (byte) ((value & 0xFF00) >> 8);
6652
	this.bCodeStream[this.classFileOffset++] = (byte) ((value & 0xFF00) >> 8);
6668
	this.bCodeStream[this.classFileOffset++] = (byte) (value & 0xFF);
6653
	this.bCodeStream[this.classFileOffset++] = (byte) (value & 0xFF);
6669
}
6654
}
6655
6670
protected void writeSignedWord(int pos, int value) {
6656
protected void writeSignedWord(int pos, int value) {
6671
	int currentOffset = this.startingClassFileOffset + pos;
6657
	int currentOffset = this.startingClassFileOffset + pos;
6672
	if (currentOffset + 3 >= this.bCodeStream.length) {
6658
	if (currentOffset + 3 >= this.bCodeStream.length) {
Lines 6677-6682 Link Here
6677
	this.bCodeStream[currentOffset++] = (byte) ((value & 0xFF00) >> 8);
6663
	this.bCodeStream[currentOffset++] = (byte) ((value & 0xFF00) >> 8);
6678
	this.bCodeStream[currentOffset++] = (byte) (value & 0xFF);
6664
	this.bCodeStream[currentOffset++] = (byte) (value & 0xFF);
6679
}
6665
}
6666
6680
/**
6667
/**
6681
 * Write a unsigned 16 bits value into the byte array
6668
 * Write a unsigned 16 bits value into the byte array
6682
 * @param value the unsigned short
6669
 * @param value the unsigned short
Lines 6687-6692 Link Here
6687
	this.bCodeStream[this.classFileOffset++] = (byte) (value >>> 8);
6674
	this.bCodeStream[this.classFileOffset++] = (byte) (value >>> 8);
6688
	this.bCodeStream[this.classFileOffset++] = (byte) value;
6675
	this.bCodeStream[this.classFileOffset++] = (byte) value;
6689
}
6676
}
6677
6690
protected void writeWidePosition(BranchLabel label) {
6678
protected void writeWidePosition(BranchLabel label) {
6691
	int labelPos = label.position;
6679
	int labelPos = label.position;
6692
	int offset = labelPos - this.position + 1;
6680
	int offset = labelPos - this.position + 1;
Lines 6698-6704 Link Here
6698
		this.writeSignedWord(forward, offset);
6686
		this.writeSignedWord(forward, offset);
6699
	}
6687
	}
6700
}
6688
}
6701
public void resetInWideMode() {
6702
	this.wideMode = true;
6703
}
6704
}
6689
}
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/ExceptionLabel.java (-1 lines)
Lines 27-33 Link Here
27
public void place() {
27
public void place() {
28
	// register the handler inside the codeStream then normal place
28
	// register the handler inside the codeStream then normal place
29
	this.codeStream.registerExceptionHandler(this);
29
	this.codeStream.registerExceptionHandler(this);
30
	if (CodeStream.DEBUG) System.out.println("\t\t\t\t<place at: "+this.codeStream.position+" - "+ this); //$NON-NLS-1$ //$NON-NLS-2$
31
	this.position = this.codeStream.getPosition();
30
	this.position = this.codeStream.getPosition();
32
}
31
}
33
32
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java (-4 / +6 lines)
Lines 120-125 Link Here
120
    public static final char[] HasNextSignature = "()Z".toCharArray();//$NON-NLS-1$
120
    public static final char[] HasNextSignature = "()Z".toCharArray();//$NON-NLS-1$
121
    public static final char[] Init = "<init>".toCharArray(); //$NON-NLS-1$
121
    public static final char[] Init = "<init>".toCharArray(); //$NON-NLS-1$
122
    public static final char[] IntConstrSignature = "(I)V".toCharArray(); //$NON-NLS-1$
122
    public static final char[] IntConstrSignature = "(I)V".toCharArray(); //$NON-NLS-1$
123
    public static final char[] ITERATOR_NAME = "iterator".toCharArray(); //$NON-NLS-1$
124
    public static final char[] ITERATOR_SIGNATURE = "()Ljava/util/Iterator;".toCharArray(); //$NON-NLS-1$
123
    public static final char[] Intern = "intern".toCharArray(); //$NON-NLS-1$
125
    public static final char[] Intern = "intern".toCharArray(); //$NON-NLS-1$
124
    public static final char[] InternSignature = GetMessageSignature;
126
    public static final char[] InternSignature = GetMessageSignature;
125
    public static final char[] IntIntegerSignature = "(I)Ljava/lang/Integer;".toCharArray(); //$NON-NLS-1$
127
    public static final char[] IntIntegerSignature = "(I)Ljava/lang/Integer;".toCharArray(); //$NON-NLS-1$
Lines 685-695 Link Here
685
    }
687
    }
686
    return index;
688
    return index;
687
}
689
}
688
public int literalIndexForMethod(TypeBinding binding, char[] selector, char[] signature, boolean isInterface) {
690
public int literalIndexForMethod(TypeBinding declaringClass, char[] selector, char[] signature, boolean isInterface) {
689
    if (binding.isNestedType()) {
691
    if (declaringClass.isNestedType()) {
690
        this.classFile.recordInnerClasses(binding);
692
        this.classFile.recordInnerClasses(declaringClass);
691
    }
693
    }
692
    return this.literalIndexForMethod(binding.constantPoolName(), selector, signature, isInterface);
694
    return this.literalIndexForMethod(declaringClass.constantPoolName(), selector, signature, isInterface);
693
}
695
}
694
public int literalIndexForNameAndType(char[] name, char[] signature) {
696
public int literalIndexForNameAndType(char[] name, char[] signature) {
695
    int index;
697
    int index;
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/BranchLabel.java (-1 lines)
Lines 181-187 Link Here
181
* Place the label. If we have forward references resolve them.
181
* Place the label. If we have forward references resolve them.
182
*/
182
*/
183
public void place() { // Currently lacking wide support.
183
public void place() { // Currently lacking wide support.
184
	if (CodeStream.DEBUG) System.out.println("\t\t\t\t<place at: "+this.codeStream.position+" - "+ this); //$NON-NLS-1$ //$NON-NLS-2$
185
//	if ((this.tagBits & USED) == 0 && this.forwardReferenceCount == 0) {
184
//	if ((this.tagBits & USED) == 0 && this.forwardReferenceCount == 0) {
186
//		return;
185
//		return;
187
//	}
186
//	}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java (-2 / +2 lines)
Lines 44-50 Link Here
44
		if (syntheticWriteAccessor == null) {
44
		if (syntheticWriteAccessor == null) {
45
			codeStream.putstatic(fieldBinding);
45
			codeStream.putstatic(fieldBinding);
46
		} else {
46
		} else {
47
			codeStream.invokestatic(syntheticWriteAccessor);
47
			codeStream.invoke(Opcodes.OPC_invokestatic, syntheticWriteAccessor, null /* default declaringClass */);
48
		}
48
		}
49
	} else { // Stack:  [owner][new field value]  ---> [new field value][owner][new field value]
49
	} else { // Stack:  [owner][new field value]  ---> [new field value][owner][new field value]
50
		if (valueRequired) {
50
		if (valueRequired) {
Lines 57-63 Link Here
57
		if (syntheticWriteAccessor == null) {
57
		if (syntheticWriteAccessor == null) {
58
			codeStream.putfield(fieldBinding);
58
			codeStream.putfield(fieldBinding);
59
		} else {
59
		} else {
60
			codeStream.invokestatic(syntheticWriteAccessor);
60
			codeStream.invoke(Opcodes.OPC_invokestatic, syntheticWriteAccessor, null /* default declaringClass */);
61
		}
61
		}
62
	}
62
	}
63
	codeStream.recordPositionsFrom(pc, this.sourceStart);
63
	codeStream.recordPositionsFrom(pc, this.sourceStart);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java (-6 / +7 lines)
Lines 14-19 Link Here
14
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.ASTVisitor;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
17
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
17
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
20
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
Lines 377-383 Link Here
377
					if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
378
					if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
378
						codeStream.getstatic(fieldBinding);
379
						codeStream.getstatic(fieldBinding);
379
					} else {
380
					} else {
380
						codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
381
						codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
381
					}
382
					}
382
				} else {
383
				} else {
383
					if (!valueRequired
384
					if (!valueRequired
Lines 399-405 Link Here
399
					if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
400
					if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
400
						codeStream.getfield(fieldBinding);
401
						codeStream.getfield(fieldBinding);
401
					} else {
402
					} else {
402
						codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
403
						codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
403
					}
404
					}
404
				}
405
				}
405
				break;
406
				break;
Lines 474-480 Link Here
474
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
475
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
475
					codeStream.getstatic(fieldBinding);
476
					codeStream.getstatic(fieldBinding);
476
				} else {
477
				} else {
477
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
478
					codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
478
				}
479
				}
479
			} else {
480
			} else {
480
				if ((this.bits & ASTNode.DepthMASK) != 0) {
481
				if ((this.bits & ASTNode.DepthMASK) != 0) {
Lines 488-494 Link Here
488
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
489
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
489
					codeStream.getfield(fieldBinding);
490
					codeStream.getfield(fieldBinding);
490
				} else {
491
				} else {
491
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
492
					codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
492
				}
493
				}
493
			}
494
			}
494
			break;
495
			break;
Lines 587-593 Link Here
587
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
588
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
588
					codeStream.getstatic(fieldBinding);
589
					codeStream.getstatic(fieldBinding);
589
				} else {
590
				} else {
590
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
591
					codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
591
				}
592
				}
592
			} else {
593
			} else {
593
				if ((this.bits & ASTNode.DepthMASK) != 0) {
594
				if ((this.bits & ASTNode.DepthMASK) != 0) {
Lines 601-607 Link Here
601
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
602
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
602
					codeStream.getfield(fieldBinding);
603
					codeStream.getfield(fieldBinding);
603
				} else {
604
				} else {
604
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
605
					codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
605
				}
606
				}
606
			}
607
			}
607
			TypeBinding operandType;
608
			TypeBinding operandType;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-2 / +3 lines)
Lines 13-18 Link Here
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
15
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
16
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
16
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
17
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
17
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
18
import org.eclipse.jdt.internal.compiler.impl.Constant;
19
import org.eclipse.jdt.internal.compiler.impl.Constant;
Lines 138-144 Link Here
138
139
139
		// invoke constructor
140
		// invoke constructor
140
		if (this.syntheticAccessor == null) {
141
		if (this.syntheticAccessor == null) {
141
			codeStream.invokespecial(this.codegenBinding);
142
			codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */);
142
		} else {
143
		} else {
143
			// synthetic accessor got some extra arguments appended to its signature, which need values
144
			// synthetic accessor got some extra arguments appended to its signature, which need values
144
			for (int i = 0,
145
			for (int i = 0,
Lines 147-153 Link Here
147
				i++) {
148
				i++) {
148
				codeStream.aconst_null();
149
				codeStream.aconst_null();
149
			}
150
			}
150
			codeStream.invokespecial(this.syntheticAccessor);
151
			codeStream.invoke(Opcodes.OPC_invokespecial, this.syntheticAccessor, null /* default declaringClass */);
151
		}
152
		}
152
		if (valueRequired) {
153
		if (valueRequired) {
153
			codeStream.generateImplicitConversion(this.implicitConversion);
154
			codeStream.generateImplicitConversion(this.implicitConversion);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java (-1 / +1 lines)
Lines 156-162 Link Here
156
			if (resolvedType.isEnum()) {
156
			if (resolvedType.isEnum()) {
157
				if (needSwitch) {
157
				if (needSwitch) {
158
					// go through the translation table
158
					// go through the translation table
159
					codeStream.invokestatic(this.synthetic);
159
					codeStream.invoke(Opcodes.OPC_invokestatic, this.synthetic, null /* default declaringClass */);
160
					this.expression.generateCode(currentScope, codeStream, true);
160
					this.expression.generateCode(currentScope, codeStream, true);
161
					// get enum constant ordinal()
161
					// get enum constant ordinal()
162
					codeStream.invokeEnumOrdinal(resolvedType.constantPoolName());
162
					codeStream.invokeEnumOrdinal(resolvedType.constantPoolName());
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (-2 / +2 lines)
Lines 115-121 Link Here
115
	}
115
	}
116
	// invoke constructor
116
	// invoke constructor
117
	if (this.syntheticAccessor == null) {
117
	if (this.syntheticAccessor == null) {
118
		codeStream.invokespecial(this.codegenBinding);
118
		codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */);
119
	} else {
119
	} else {
120
		// synthetic accessor got some extra arguments appended to its signature, which need values
120
		// synthetic accessor got some extra arguments appended to its signature, which need values
121
		for (int i = 0,
121
		for (int i = 0,
Lines 124-130 Link Here
124
			i++) {
124
			i++) {
125
			codeStream.aconst_null();
125
			codeStream.aconst_null();
126
		}
126
		}
127
		codeStream.invokespecial(this.syntheticAccessor);
127
		codeStream.invoke(Opcodes.OPC_invokespecial, this.syntheticAccessor, null /* default declaringClass */);
128
	}
128
	}
129
	if (valueRequired) {
129
	if (valueRequired) {
130
		codeStream.generateImplicitConversion(this.implicitConversion);
130
		codeStream.generateImplicitConversion(this.implicitConversion);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java (-16 / +3 lines)
Lines 12-19 Link Here
12
12
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
16
import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
15
import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
17
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
17
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext;
19
import org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext;
Lines 23-29 Link Here
23
import org.eclipse.jdt.internal.compiler.lookup.Binding;
23
import org.eclipse.jdt.internal.compiler.lookup.Binding;
24
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
24
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
25
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
25
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
Lines 62-68 Link Here
62
61
63
	int postCollectionInitStateIndex = -1;
62
	int postCollectionInitStateIndex = -1;
64
	int mergedInitStateIndex = -1;
63
	int mergedInitStateIndex = -1;
65
64
	
66
	public ForeachStatement(
65
	public ForeachStatement(
67
		LocalDeclaration elementVariable,
66
		LocalDeclaration elementVariable,
68
		int start) {
67
		int start) {
Lines 212-230 Link Here
212
			case GENERIC_ITERABLE :
211
			case GENERIC_ITERABLE :
213
				this.collection.generateCode(this.scope, codeStream, true);
212
				this.collection.generateCode(this.scope, codeStream, true);
214
				// declaringClass.iterator();
213
				// declaringClass.iterator();
215
				MethodBinding iteratorMethodBinding =
214
				codeStream.invokeIterableIterator(this.iteratorReceiverType);
216
					new MethodBinding(
217
							ClassFileConstants.AccPublic,
218
							"iterator".toCharArray(),//$NON-NLS-1$
219
							this.scope.getJavaUtilIterator(),
220
							Binding.NO_PARAMETERS,
221
							Binding.NO_EXCEPTIONS,
222
							(ReferenceBinding) this.iteratorReceiverType.erasure());
223
				if (this.iteratorReceiverType.isInterface()) {
224
					codeStream.invokeinterface(iteratorMethodBinding);
225
				} else {
226
					codeStream.invokevirtual(iteratorMethodBinding);
227
				}
228
				codeStream.store(this.indexVariable, false);
215
				codeStream.store(this.indexVariable, false);
229
				codeStream.addVariable(this.indexVariable);
216
				codeStream.addVariable(this.indexVariable);
230
				break;
217
				break;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java (-2 / +3 lines)
Lines 13-18 Link Here
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
15
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
16
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
16
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
17
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
17
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
18
import org.eclipse.jdt.internal.compiler.lookup.Binding;
19
import org.eclipse.jdt.internal.compiler.lookup.Binding;
Lines 148-156 Link Here
148
					i++) {
149
					i++) {
149
					codeStream.aconst_null();
150
					codeStream.aconst_null();
150
				}
151
				}
151
				codeStream.invokespecial(this.syntheticAccessor);
152
				codeStream.invoke(Opcodes.OPC_invokespecial, this.syntheticAccessor, null /* default declaringClass */);
152
			} else {
153
			} else {
153
				codeStream.invokespecial(this.codegenBinding);
154
				codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */);
154
			}
155
			}
155
			codeStream.recordPositionsFrom(pc, this.sourceStart);
156
			codeStream.recordPositionsFrom(pc, this.sourceStart);
156
		} finally {
157
		} finally {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java (-6 / +7 lines)
Lines 14-19 Link Here
14
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.ASTVisitor;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
17
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
17
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
20
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
Lines 233-239 Link Here
233
					codeStream.getfield(this.codegenBinding);
234
					codeStream.getfield(this.codegenBinding);
234
				}
235
				}
235
			} else {
236
			} else {
236
				codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]);
237
				codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
237
			}
238
			}
238
			// required cast must occur even if no value is required
239
			// required cast must occur even if no value is required
239
			if (this.genericCast != null) codeStream.checkcast(this.genericCast);
240
			if (this.genericCast != null) codeStream.checkcast(this.genericCast);
Lines 262-268 Link Here
262
					if (accessor == null) {
263
					if (accessor == null) {
263
						codeStream.getstatic(this.codegenBinding);
264
						codeStream.getstatic(this.codegenBinding);
264
					} else {
265
					} else {
265
						codeStream.invokestatic(accessor);
266
						codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
266
					}
267
					}
267
					switch (this.codegenBinding.type.id) {
268
					switch (this.codegenBinding.type.id) {
268
						case T_long :
269
						case T_long :
Lines 295-308 Link Here
295
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
296
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
296
			codeStream.getstatic(this.codegenBinding);
297
			codeStream.getstatic(this.codegenBinding);
297
		} else {
298
		} else {
298
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]);
299
			codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
299
		}
300
		}
300
	} else {
301
	} else {
301
		codeStream.dup();
302
		codeStream.dup();
302
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
303
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
303
			codeStream.getfield(this.codegenBinding);
304
			codeStream.getfield(this.codegenBinding);
304
		} else {
305
		} else {
305
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]);
306
			codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
306
		}
307
		}
307
	}
308
	}
308
	int operationTypeID;
309
	int operationTypeID;
Lines 346-359 Link Here
346
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
347
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
347
			codeStream.getstatic(this.codegenBinding);
348
			codeStream.getstatic(this.codegenBinding);
348
		} else {
349
		} else {
349
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]);
350
			codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
350
		}
351
		}
351
	} else {
352
	} else {
352
		codeStream.dup();
353
		codeStream.dup();
353
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
354
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
354
			codeStream.getfield(this.codegenBinding);
355
			codeStream.getfield(this.codegenBinding);
355
		} else {
356
		} else {
356
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]);
357
			codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
357
		}
358
		}
358
	}
359
	}
359
	TypeBinding operandType;
360
	TypeBinding operandType;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-42 / +44 lines)
Lines 15-20 Link Here
15
import org.eclipse.jdt.internal.compiler.ASTVisitor;
15
import org.eclipse.jdt.internal.compiler.ASTVisitor;
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
17
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
17
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
18
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
18
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
19
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
19
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
20
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
20
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
21
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
Lines 34-40 Link Here
34
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
35
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
35
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
36
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
36
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
37
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
37
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
38
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
38
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
39
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
39
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
40
40
Lines 96-107 Link Here
96
	    		? compileTimeType  // unboxing: checkcast before conversion
96
	    		? compileTimeType  // unboxing: checkcast before conversion
97
	    		: runtimeTimeType;
97
	    		: runtimeTimeType;
98
	        this.valueCast = originalType.genericCast(targetType);
98
	        this.valueCast = originalType.genericCast(targetType);
99
		} 	else if (this.actualReceiverType.isArrayType()
99
		} 	else if (this.binding == scope.environment().arrayClone
100
						&& runtimeTimeType.id != TypeIds.T_JavaLangObject
100
				&& runtimeTimeType.id != TypeIds.T_JavaLangObject
101
						&& this.binding.parameters == Binding.NO_PARAMETERS
101
				&& scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
102
						&& scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5
102
					// from 1.5 source level on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast
103
						&& CharOperation.equals(this.binding.selector, TypeConstants.CLONE)) {
104
					// from 1.5 compliant mode on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast
105
			this.valueCast = runtimeTimeType;
103
			this.valueCast = runtimeTimeType;
106
		}
104
		}
107
        if (this.valueCast instanceof ReferenceBinding) {
105
        if (this.valueCast instanceof ReferenceBinding) {
Lines 148-170 Link Here
148
	}
146
	}
149
	// generate arguments
147
	// generate arguments
150
	generateArguments(this.binding, this.arguments, currentScope, codeStream);
148
	generateArguments(this.binding, this.arguments, currentScope, codeStream);
149
151
	// actual message invocation
150
	// actual message invocation
152
	if (this.syntheticAccessor == null){
151
	if (this.syntheticAccessor == null){
152
		TypeBinding constantPoolDeclaringClass = getConstantPoolDeclaringClass(currentScope);
153
		if (isStatic){
153
		if (isStatic){
154
			codeStream.invokestatic(this.codegenBinding);
154
			codeStream.invoke(Opcodes.OPC_invokestatic, this.codegenBinding, constantPoolDeclaringClass);
155
		} else if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){
156
			codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, constantPoolDeclaringClass);
155
		} else {
157
		} else {
156
			if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){
158
			if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type
157
				codeStream.invokespecial(this.codegenBinding);
159
				codeStream.invoke(Opcodes.OPC_invokeinterface, this.codegenBinding, constantPoolDeclaringClass);
158
			} else {
160
			} else {
159
				if (this.codegenBinding.declaringClass.isInterface()) { // interface or annotation type
161
				codeStream.invoke(Opcodes.OPC_invokevirtual, this.codegenBinding, constantPoolDeclaringClass);
160
					codeStream.invokeinterface(this.codegenBinding);
161
				} else {
162
					codeStream.invokevirtual(this.codegenBinding);
163
				}
164
			}
162
			}
165
		}
163
		}
166
	} else {
164
	} else {
167
		codeStream.invokestatic(this.syntheticAccessor);
165
		codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessor, null /* default declaringClass */);
168
	}
166
	}
169
	// required cast must occur even if no value is required
167
	// required cast must occur even if no value is required
170
	if (this.valueCast != null) codeStream.checkcast(this.valueCast);
168
	if (this.valueCast != null) codeStream.checkcast(this.valueCast);
Lines 188-194 Link Here
188
	}
186
	}
189
	codeStream.recordPositionsFrom(pc, (int)(this.nameSourcePosition >>> 32)); // highlight selector
187
	codeStream.recordPositionsFrom(pc, (int)(this.nameSourcePosition >>> 32)); // highlight selector
190
}
188
}
191
192
/**
189
/**
193
 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
190
 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
194
 */
191
 */
Lines 196-201 Link Here
196
	return this.genericTypeArguments;
193
	return this.genericTypeArguments;
197
}
194
}
198
195
196
protected TypeBinding getConstantPoolDeclaringClass(BlockScope currentScope) {
197
	// constantpool declaringClass
198
	TypeBinding constantPoolDeclaringClass = this.codegenBinding.declaringClass;
199
	// Post 1.4.0 target, array clone() invocations are qualified with array type
200
	// This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding)
201
	if (this.codegenBinding == currentScope.environment().arrayClone) {
202
		CompilerOptions options = currentScope.compilerOptions();
203
		if (options.sourceLevel > ClassFileConstants.JDK1_4 ) {
204
			constantPoolDeclaringClass = this.actualReceiverType.erasure();
205
		}
206
	} else {
207
		// if the binding declaring class is not visible, need special action
208
		// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
209
		// NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type
210
		// and not from Object or implicit static method call.
211
		if (constantPoolDeclaringClass != this.actualReceiverType && this.receiverGenericCast == null && !this.actualReceiverType.isArrayType()) {
212
			CompilerOptions options = currentScope.compilerOptions();
213
			if ((options.targetJDK >= ClassFileConstants.JDK1_2
214
						&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(this.receiver.isImplicitThis() && this.codegenBinding.isStatic()))
215
						&& this.binding.declaringClass.id != TypeIds.T_JavaLangObject) // no change for Object methods
216
					|| !this.binding.declaringClass.canBeSeenBy(currentScope)) {
217
				constantPoolDeclaringClass = this.actualReceiverType.erasure();
218
			}
219
		}				
220
	}
221
	return constantPoolDeclaringClass;
222
}
223
199
public boolean isSuperAccess() {
224
public boolean isSuperAccess() {
200
	return this.receiver.isSuper();
225
	return this.receiver.isSuper();
201
}
226
}
Lines 239-264 Link Here
239
			return;
264
			return;
240
		}
265
		}
241
	}
266
	}
242
243
	// if the binding declaring class is not visible, need special action
244
	// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
245
	// NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type
246
	// and not from Object or implicit static method call.
247
	if (this.binding.declaringClass != this.actualReceiverType
248
			&& this.receiverGenericCast == null
249
			&& !this.actualReceiverType.isArrayType()) {
250
		CompilerOptions options = currentScope.compilerOptions();
251
		if ((options.targetJDK >= ClassFileConstants.JDK1_2
252
				&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(this.receiver.isImplicitThis() && this.codegenBinding.isStatic()))
253
				&& this.binding.declaringClass.id != TypeIds.T_JavaLangObject) // no change for Object methods
254
			|| !this.binding.declaringClass.canBeSeenBy(currentScope)) {
255
256
			this.codegenBinding = currentScope.enclosingSourceType().getUpdatedMethodBinding(
257
			        										this.codegenBinding, (ReferenceBinding) this.actualReceiverType.erasure());
258
		}
259
		// Post 1.4.0 target, array clone() invocations are qualified with array type
260
		// This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding)
261
	}
262
}
267
}
263
public int nullStatus(FlowInfo flowInfo) {
268
public int nullStatus(FlowInfo flowInfo) {
264
	return FlowInfo.UNKNOWN;
269
	return FlowInfo.UNKNOWN;
Lines 507-517 Link Here
507
	if (isMethodUseDeprecated(this.binding, scope, true))
512
	if (isMethodUseDeprecated(this.binding, scope, true))
508
		scope.problemReporter().deprecatedMethod(this.binding, this);
513
		scope.problemReporter().deprecatedMethod(this.binding, this);
509
514
510
	// from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)
515
	// from 1.5 source level on, array#clone() returns the array type (but binding still shows Object)
511
	if (this.actualReceiverType.isArrayType()
516
	if (this.binding == scope.environment().arrayClone && compilerOptions.sourceLevel >= ClassFileConstants.JDK1_5) {
512
			&& this.binding.parameters == Binding.NO_PARAMETERS
513
			&& compilerOptions.complianceLevel >= ClassFileConstants.JDK1_5
514
			&& CharOperation.equals(this.binding.selector, TypeConstants.CLONE)) {
515
		this.resolvedType = this.actualReceiverType;
517
		this.resolvedType = this.actualReceiverType;
516
	} else {
518
	} else {
517
		TypeBinding returnType = this.binding.returnType;
519
		TypeBinding returnType = this.binding.returnType;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java (-7 / +8 lines)
Lines 14-19 Link Here
14
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.ASTVisitor;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
17
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
17
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
20
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
Lines 401-407 Link Here
401
								codeStream.getfield(lastFieldBinding);
402
								codeStream.getfield(lastFieldBinding);
402
							}
403
							}
403
						} else {
404
						} else {
404
							codeStream.invokestatic(accessor);
405
							codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
405
						}
406
						}
406
						if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast);
407
						if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast);
407
						if (valueRequired) {
408
						if (valueRequired) {
Lines 452-465 Link Here
452
		if (accessor == null) {
453
		if (accessor == null) {
453
			codeStream.getstatic(lastFieldBinding);
454
			codeStream.getstatic(lastFieldBinding);
454
		} else {
455
		} else {
455
			codeStream.invokestatic(accessor);
456
			codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
456
		}
457
		}
457
	} else {
458
	} else {
458
		codeStream.dup();
459
		codeStream.dup();
459
		if (accessor == null) {
460
		if (accessor == null) {
460
			codeStream.getfield(lastFieldBinding);
461
			codeStream.getfield(lastFieldBinding);
461
		} else {
462
		} else {
462
			codeStream.invokestatic(accessor);
463
			codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
463
		}
464
		}
464
	}
465
	}
465
	// the last field access is a write access
466
	// the last field access is a write access
Lines 501-514 Link Here
501
		if (accessor == null) {
502
		if (accessor == null) {
502
			codeStream.getstatic(lastFieldBinding);
503
			codeStream.getstatic(lastFieldBinding);
503
		} else {
504
		} else {
504
			codeStream.invokestatic(accessor);
505
			codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
505
		}
506
		}
506
	} else {
507
	} else {
507
		codeStream.dup();
508
		codeStream.dup();
508
		if (accessor == null) {
509
		if (accessor == null) {
509
			codeStream.getfield(lastFieldBinding);
510
			codeStream.getfield(lastFieldBinding);
510
		} else {
511
		} else {
511
			codeStream.invokestatic(accessor);
512
			codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
512
		}
513
		}
513
	}
514
	}
514
	TypeBinding requiredGenericCast = getGenericCast(this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length);
515
	TypeBinding requiredGenericCast = getGenericCast(this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length);
Lines 628-634 Link Here
628
								codeStream.getfield(lastFieldBinding);
629
								codeStream.getfield(lastFieldBinding);
629
							}
630
							}
630
						} else {
631
						} else {
631
							codeStream.invokestatic(accessor);
632
							codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
632
						}
633
						}
633
						if (lastGenericCast != null) codeStream.checkcast(lastGenericCast);
634
						if (lastGenericCast != null) codeStream.checkcast(lastGenericCast);
634
						if (!needValue) codeStream.pop();
635
						if (!needValue) codeStream.pop();
Lines 641-647 Link Here
641
									if (accessor == null) {
642
									if (accessor == null) {
642
										codeStream.getstatic(lastFieldBinding);
643
										codeStream.getstatic(lastFieldBinding);
643
									} else {
644
									} else {
644
										codeStream.invokestatic(accessor);
645
										codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
645
									}
646
									}
646
									codeStream.pop();
647
									codeStream.pop();
647
								}
648
								}
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java (-1 / +2 lines)
Lines 14-19 Link Here
14
import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
14
import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
15
import org.eclipse.jdt.internal.compiler.ast.TryStatement;
15
import org.eclipse.jdt.internal.compiler.ast.TryStatement;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
17
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
17
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.impl.Constant;
20
import org.eclipse.jdt.internal.compiler.impl.Constant;
Lines 83-89 Link Here
83
	}
84
	}
84
85
85
	// generate the invoke virtual to "setResult(Object,Class)"
86
	// generate the invoke virtual to "setResult(Object,Class)"
86
	codeStream.invokevirtual(this.setResultMethod);
87
	codeStream.invoke(Opcodes.OPC_invokevirtual, this.setResultMethod, null /* default declaringClass */);
87
}
88
}
88
/**
89
/**
89
 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
90
 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java (-2 / +3 lines)
Lines 17-22 Link Here
17
import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
17
import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
19
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
20
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
20
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
21
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
21
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
22
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
22
import org.eclipse.jdt.internal.compiler.impl.Constant;
23
import org.eclipse.jdt.internal.compiler.impl.Constant;
Lines 222-235 Link Here
222
			if (accessor == null) {
223
			if (accessor == null) {
223
				codeStream.getstatic(lastFieldBinding);
224
				codeStream.getstatic(lastFieldBinding);
224
			} else {
225
			} else {
225
				codeStream.invokestatic(accessor);
226
				codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
226
			}
227
			}
227
		} else {
228
		} else {
228
			codeStream.dup();
229
			codeStream.dup();
229
			if (accessor == null) {
230
			if (accessor == null) {
230
				codeStream.getfield(lastFieldBinding);
231
				codeStream.getfield(lastFieldBinding);
231
			} else {
232
			} else {
232
				codeStream.invokestatic(accessor);
233
				codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
233
			}
234
			}
234
		}
235
		}
235
236
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java (-11 / +11 lines)
Lines 17-22 Link Here
17
import org.eclipse.jdt.internal.compiler.ast.NameReference;
17
import org.eclipse.jdt.internal.compiler.ast.NameReference;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
19
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
20
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
20
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
21
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
21
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
22
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
22
import org.eclipse.jdt.internal.compiler.impl.Constant;
23
import org.eclipse.jdt.internal.compiler.impl.Constant;
Lines 32-38 Link Here
32
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
33
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
33
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
34
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
34
35
35
public class CodeSnippetMessageSend extends MessageSend implements ProblemReasons, EvaluationConstants {
36
public class CodeSnippetMessageSend extends MessageSend {
36
	EvaluationContext evaluationContext;
37
	EvaluationContext evaluationContext;
37
	FieldBinding delegateThis;
38
	FieldBinding delegateThis;
38
/**
39
/**
Lines 78-94 Link Here
78
		// generate arguments
79
		// generate arguments
79
		generateArguments(this.binding, this.arguments, currentScope, codeStream);
80
		generateArguments(this.binding, this.arguments, currentScope, codeStream);
80
		// actual message invocation
81
		// actual message invocation
82
		TypeBinding constantPoolDeclaringClass = getConstantPoolDeclaringClass(currentScope);
81
		if (isStatic) {
83
		if (isStatic) {
82
			codeStream.invokestatic(this.codegenBinding);
84
			codeStream.invoke(Opcodes.OPC_invokestatic, this.codegenBinding, constantPoolDeclaringClass);
85
		} else if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){
86
			codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, constantPoolDeclaringClass);
83
		} else {
87
		} else {
84
			if (this.receiver.isSuper()) {
88
			if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type
85
				codeStream.invokespecial(this.codegenBinding);
89
				codeStream.invoke(Opcodes.OPC_invokeinterface, this.codegenBinding, constantPoolDeclaringClass);
86
			} else {
90
			} else {
87
				if (this.codegenBinding.declaringClass.isInterface()) {
91
				codeStream.invoke(Opcodes.OPC_invokevirtual, this.codegenBinding, constantPoolDeclaringClass);
88
					codeStream.invokeinterface(this.codegenBinding);
89
				} else {
90
					codeStream.invokevirtual(this.codegenBinding);
91
				}
92
			}
92
			}
93
		}
93
		}
94
	} else {
94
	} else {
Lines 273-281 Link Here
273
			: scope.getMethod(this.actualReceiverType, this.selector, argumentTypes, this);
273
			: scope.getMethod(this.actualReceiverType, this.selector, argumentTypes, this);
274
	if (!this.binding.isValidBinding()) {
274
	if (!this.binding.isValidBinding()) {
275
		if (this.binding instanceof ProblemMethodBinding
275
		if (this.binding instanceof ProblemMethodBinding
276
			&& ((ProblemMethodBinding) this.binding).problemId() == NotVisible) {
276
			&& ((ProblemMethodBinding) this.binding).problemId() == ProblemReasons.NotVisible) {
277
			if (this.evaluationContext.declaringTypeName != null) {
277
			if (this.evaluationContext.declaringTypeName != null) {
278
				this.delegateThis = scope.getField(scope.enclosingSourceType(), DELEGATE_THIS, this);
278
				this.delegateThis = scope.getField(scope.enclosingSourceType(), EvaluationConstants.DELEGATE_THIS, this);
279
				if (this.delegateThis == null){ // if not found then internal error, field should have been found
279
				if (this.delegateThis == null){ // if not found then internal error, field should have been found
280
					this.constant = Constant.NotAConstant;
280
					this.constant = Constant.NotAConstant;
281
					scope.problemReporter().invalidMethod(this, this.binding);
281
					scope.problemReporter().invalidMethod(this, this.binding);
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java (-1 / +2 lines)
Lines 14-19 Link Here
14
import org.eclipse.jdt.internal.compiler.ast.CastExpression;
14
import org.eclipse.jdt.internal.compiler.ast.CastExpression;
15
import org.eclipse.jdt.internal.compiler.ast.Expression;
15
import org.eclipse.jdt.internal.compiler.ast.Expression;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
17
import org.eclipse.jdt.internal.compiler.codegen.Opcodes;
17
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
18
import org.eclipse.jdt.internal.compiler.impl.Constant;
19
import org.eclipse.jdt.internal.compiler.impl.Constant;
19
import org.eclipse.jdt.internal.compiler.lookup.Binding;
20
import org.eclipse.jdt.internal.compiler.lookup.Binding;
Lines 73-79 Link Here
73
				this);
74
				this);
74
		}
75
		}
75
		// invoke constructor
76
		// invoke constructor
76
		codeStream.invokespecial(this.codegenBinding);
77
		codeStream.invoke(Opcodes.OPC_invokespecial, this.codegenBinding, null /* default declaringClass */);
77
	} else {
78
	} else {
78
		// private emulation using reflect
79
		// private emulation using reflect
79
		codeStream.generateEmulationForConstructor(currentScope, this.codegenBinding);
80
		codeStream.generateEmulationForConstructor(currentScope, this.codegenBinding);
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java (-3 / +3 lines)
Lines 271-277 Link Here
271
		if (!((ReferenceBinding)leafType).canBeSeenBy(this)) {
271
		if (!((ReferenceBinding)leafType).canBeSeenBy(this)) {
272
			return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible);
272
			return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible);
273
		}
273
		}
274
		if (CharOperation.equals(fieldName, LENGTH))
274
		if (CharOperation.equals(fieldName, TypeConstants.LENGTH))
275
			return ArrayBinding.ArrayLength;
275
			return ArrayBinding.ArrayLength;
276
		return null;
276
		return null;
277
	}
277
	}
Lines 371-378 Link Here
371
	MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
371
	MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
372
	if (methodBinding != null) {
372
	if (methodBinding != null) {
373
		// handle the method clone() specially... cannot be protected or throw exceptions
373
		// handle the method clone() specially... cannot be protected or throw exceptions
374
		if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, CLONE))
374
		if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.CLONE))
375
			return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, CLONE, methodBinding.returnType, argumentTypes, null, object);
375
			return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, methodBinding.returnType, argumentTypes, null, object);
376
		if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
376
		if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
377
			return methodBinding;
377
			return methodBinding;
378
	}
378
	}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java (-8 lines)
Lines 391-404 Link Here
391
	return uniqueKey;
391
	return uniqueKey;
392
}
392
}
393
393
394
/*
395
 * Answer the declaring class to use in the constant pool
396
 * may not be a reference binding (see subtypes)
397
 */
398
public TypeBinding constantPoolDeclaringClass() {
399
	return this.declaringClass;
400
}
401
402
/* Answer the receiver's constant pool name.
394
/* Answer the receiver's constant pool name.
403
*
395
*
404
* <init> for constructors
396
* <init> for constructors
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (-7 / +7 lines)
Lines 154-160 Link Here
154
	int numberOfImports = numberOfStatements + 1;
154
	int numberOfImports = numberOfStatements + 1;
155
	for (int i = 0; i < numberOfStatements; i++) {
155
	for (int i = 0; i < numberOfStatements; i++) {
156
		ImportReference importReference = this.referenceContext.imports[i];
156
		ImportReference importReference = this.referenceContext.imports[i];
157
		if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(JAVA_LANG, importReference.tokens) && !importReference.isStatic()) {
157
		if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(TypeConstants.JAVA_LANG, importReference.tokens) && !importReference.isStatic()) {
158
			numberOfImports--;
158
			numberOfImports--;
159
			break;
159
			break;
160
		}
160
		}
Lines 313-319 Link Here
313
	int numberOfImports = numberOfStatements + 1;
313
	int numberOfImports = numberOfStatements + 1;
314
	for (int i = 0; i < numberOfStatements; i++) {
314
	for (int i = 0; i < numberOfStatements; i++) {
315
		ImportReference importReference = this.referenceContext.imports[i];
315
		ImportReference importReference = this.referenceContext.imports[i];
316
		if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(JAVA_LANG, importReference.tokens) && !importReference.isStatic()) {
316
		if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(TypeConstants.JAVA_LANG, importReference.tokens) && !importReference.isStatic()) {
317
			numberOfImports--;
317
			numberOfImports--;
318
			break;
318
			break;
319
		}
319
		}
Lines 569-589 Link Here
569
	// initialize the default imports if necessary... share the default java.lang.* import
569
	// initialize the default imports if necessary... share the default java.lang.* import
570
	if (this.environment.defaultImports != null) return this.environment.defaultImports;
570
	if (this.environment.defaultImports != null) return this.environment.defaultImports;
571
571
572
	Binding importBinding = this.environment.getTopLevelPackage(JAVA);
572
	Binding importBinding = this.environment.getTopLevelPackage(TypeConstants.JAVA);
573
	if (importBinding != null)
573
	if (importBinding != null)
574
		importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]);
574
		importBinding = ((PackageBinding) importBinding).getTypeOrPackage(TypeConstants.JAVA_LANG[1]);
575
575
576
	if (importBinding == null || !importBinding.isValidBinding()) {
576
	if (importBinding == null || !importBinding.isValidBinding()) {
577
		// create a proxy for the missing BinaryType
577
		// create a proxy for the missing BinaryType
578
		problemReporter().isClassPathCorrect(
578
		problemReporter().isClassPathCorrect(
579
			JAVA_LANG_OBJECT,
579
				TypeConstants.JAVA_LANG_OBJECT,
580
			this.referenceContext,
580
			this.referenceContext,
581
			this.environment.missingClassFileLocation);
581
			this.environment.missingClassFileLocation);
582
		BinaryTypeBinding missingObject = this.environment.createMissingType(null, JAVA_LANG_OBJECT);
582
		BinaryTypeBinding missingObject = this.environment.createMissingType(null, TypeConstants.JAVA_LANG_OBJECT);
583
		importBinding = missingObject.fPackage;
583
		importBinding = missingObject.fPackage;
584
	}
584
	}
585
585
586
	return this.environment.defaultImports = new ImportBinding[] {new ImportBinding(JAVA_LANG, true, importBinding, null)};
586
	return this.environment.defaultImports = new ImportBinding[] {new ImportBinding(TypeConstants.JAVA_LANG, true, importBinding, null)};
587
}
587
}
588
// NOT Public API
588
// NOT Public API
589
public final Binding getImport(char[][] compoundName, boolean onDemand, boolean isStaticImport) {
589
public final Binding getImport(char[][] compoundName, boolean onDemand, boolean isStaticImport) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/UpdatedMethodBinding.java (-25 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.lookup;
12
13
public class UpdatedMethodBinding extends MethodBinding {
14
15
	public TypeBinding updatedDeclaringClass;
16
17
	public UpdatedMethodBinding(TypeBinding updatedDeclaringClass, int modifiers, char[] selector, TypeBinding returnType, TypeBinding[] args, ReferenceBinding[] exceptions, ReferenceBinding declaringClass) {
18
		super(modifiers, selector, returnType, args, exceptions, declaringClass);
19
		this.updatedDeclaringClass = updatedDeclaringClass;
20
	}
21
22
	public TypeBinding constantPoolDeclaringClass() {
23
		return this.updatedDeclaringClass;
24
	}
25
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (+3 lines)
Lines 44-49 Link Here
44
	private final static int METHOD_EMUL = 0;
44
	private final static int METHOD_EMUL = 0;
45
	private final static int FIELD_EMUL = 1;
45
	private final static int FIELD_EMUL = 1;
46
	private final static int CLASS_LITERAL_EMUL = 2;
46
	private final static int CLASS_LITERAL_EMUL = 2;
47
	/** @deprecated */
47
	private final static int RECEIVER_TYPE_EMUL = 3;
48
	private final static int RECEIVER_TYPE_EMUL = 3;
48
49
49
	private final static int MAX_SYNTHETICS = 4;
50
	private final static int MAX_SYNTHETICS = 4;
Lines 1064-1069 Link Here
1064
public ReferenceBinding[] memberTypes() {
1065
public ReferenceBinding[] memberTypes() {
1065
	return this.memberTypes;
1066
	return this.memberTypes;
1066
}
1067
}
1068
/** @deprecated */
1067
public FieldBinding getUpdatedFieldBinding(FieldBinding targetField, ReferenceBinding newDeclaringClass) {
1069
public FieldBinding getUpdatedFieldBinding(FieldBinding targetField, ReferenceBinding newDeclaringClass) {
1068
	if (this.synthetics == null)
1070
	if (this.synthetics == null)
1069
		this.synthetics = new HashMap[MAX_SYNTHETICS];
1071
		this.synthetics = new HashMap[MAX_SYNTHETICS];
Lines 1082-1087 Link Here
1082
	}
1084
	}
1083
	return updatedField;
1085
	return updatedField;
1084
}
1086
}
1087
/** @deprecated */
1085
public MethodBinding getUpdatedMethodBinding(MethodBinding targetMethod, ReferenceBinding newDeclaringClass) {
1088
public MethodBinding getUpdatedMethodBinding(MethodBinding targetMethod, ReferenceBinding newDeclaringClass) {
1086
	if (this.synthetics == null)
1089
	if (this.synthetics == null)
1087
		this.synthetics = new HashMap[MAX_SYNTHETICS];
1090
		this.synthetics = new HashMap[MAX_SYNTHETICS];
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-51 / +44 lines)
Lines 23-29 Link Here
23
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
23
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
24
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
24
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
25
25
26
public abstract class Scope implements TypeConstants, TypeIds {
26
public abstract class Scope {
27
27
28
	/* Scope kinds */
28
	/* Scope kinds */
29
	public final static int BLOCK_SCOPE = 1;
29
	public final static int BLOCK_SCOPE = 1;
Lines 781-787 Link Here
781
			// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
781
			// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
782
			if (receiverType.isInterface() || exactMethod.canBeSeenBy(receiverType, invocationSite, this)) {
782
			if (receiverType.isInterface() || exactMethod.canBeSeenBy(receiverType, invocationSite, this)) {
783
				if (argumentTypes == Binding.NO_PARAMETERS
783
				if (argumentTypes == Binding.NO_PARAMETERS
784
				    && CharOperation.equals(selector, GETCLASS)
784
				    && CharOperation.equals(selector, TypeConstants.GETCLASS)
785
				    && exactMethod.returnType.isParameterizedType()/*1.5*/) {
785
				    && exactMethod.returnType.isParameterizedType()/*1.5*/) {
786
						return ParameterizedMethodBinding.instantiateGetClass(receiverType, exactMethod, this);
786
						return ParameterizedMethodBinding.instantiateGetClass(receiverType, exactMethod, this);
787
			    }
787
			    }
Lines 832-838 Link Here
832
			if (leafType instanceof ReferenceBinding)
832
			if (leafType instanceof ReferenceBinding)
833
				if (!((ReferenceBinding) leafType).canBeSeenBy(this))
833
				if (!((ReferenceBinding) leafType).canBeSeenBy(this))
834
					return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible);
834
					return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible);
835
			if (CharOperation.equals(fieldName, LENGTH)) {
835
			if (CharOperation.equals(fieldName, TypeConstants.LENGTH)) {
836
				if ((leafType.tagBits & TagBits.HasMissingType) != 0) {
836
				if ((leafType.tagBits & TagBits.HasMissingType) != 0) {
837
					return new ProblemFieldBinding(ArrayBinding.ArrayLength, null, fieldName, ProblemReasons.NotFound);
837
					return new ProblemFieldBinding(ArrayBinding.ArrayLength, null, fieldName, ProblemReasons.NotFound);
838
				}
838
				}
Lines 1314-1332 Link Here
1314
			if (argumentTypes == Binding.NO_PARAMETERS) {
1314
			if (argumentTypes == Binding.NO_PARAMETERS) {
1315
			    switch (selector[0]) {
1315
			    switch (selector[0]) {
1316
			        case 'c':
1316
			        case 'c':
1317
			            if (CharOperation.equals(selector, CLONE)) {
1317
			            if (CharOperation.equals(selector, TypeConstants.CLONE)) {
1318
							return new UpdatedMethodBinding(
1318
			            	return environment().computeArrayClone(methodBinding);
1319
								compilerOptions().targetJDK >= ClassFileConstants.JDK1_4 ? (TypeBinding)receiverType : (TypeBinding)object, // remember its array type for codegen purpose on target>=1.4.0
1320
								(methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic,
1321
								CLONE,
1322
								methodBinding.returnType,
1323
								argumentTypes,
1324
								null,
1325
								object);
1326
			            }
1319
			            }
1327
			            break;
1320
			            break;
1328
			        case 'g':
1321
			        case 'g':
1329
			            if (CharOperation.equals(selector, GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) {
1322
			            if (CharOperation.equals(selector, TypeConstants.GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) {
1330
							return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
1323
							return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
1331
			            }
1324
			            }
1332
			            break;
1325
			            break;
Lines 1854-1860 Link Here
1854
										}
1847
										}
1855
										// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
1848
										// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
1856
										if (argumentTypes == Binding.NO_PARAMETERS
1849
										if (argumentTypes == Binding.NO_PARAMETERS
1857
										    && CharOperation.equals(selector, GETCLASS)
1850
										    && CharOperation.equals(selector, TypeConstants.GETCLASS)
1858
										    && methodBinding.returnType.isParameterizedType()/*1.5*/) {
1851
										    && methodBinding.returnType.isParameterizedType()/*1.5*/) {
1859
												return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
1852
												return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
1860
										}
1853
										}
Lines 2014-2078 Link Here
2014
2007
2015
	public final ReferenceBinding getJavaIoSerializable() {
2008
	public final ReferenceBinding getJavaIoSerializable() {
2016
		CompilationUnitScope unitScope = compilationUnitScope();
2009
		CompilationUnitScope unitScope = compilationUnitScope();
2017
		unitScope.recordQualifiedReference(JAVA_IO_SERIALIZABLE);
2010
		unitScope.recordQualifiedReference(TypeConstants.JAVA_IO_SERIALIZABLE);
2018
		return unitScope.environment.getResolvedType(JAVA_IO_SERIALIZABLE, this);
2011
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_IO_SERIALIZABLE, this);
2019
	}
2012
	}
2020
2013
2021
	public final ReferenceBinding getJavaLangAnnotationAnnotation() {
2014
	public final ReferenceBinding getJavaLangAnnotationAnnotation() {
2022
		CompilationUnitScope unitScope = compilationUnitScope();
2015
		CompilationUnitScope unitScope = compilationUnitScope();
2023
		unitScope.recordQualifiedReference(JAVA_LANG_ANNOTATION_ANNOTATION);
2016
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ANNOTATION_ANNOTATION);
2024
		return unitScope.environment.getResolvedType(JAVA_LANG_ANNOTATION_ANNOTATION, this);
2017
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ANNOTATION_ANNOTATION, this);
2025
	}
2018
	}
2026
2019
2027
	public final ReferenceBinding getJavaLangAssertionError() {
2020
	public final ReferenceBinding getJavaLangAssertionError() {
2028
		CompilationUnitScope unitScope = compilationUnitScope();
2021
		CompilationUnitScope unitScope = compilationUnitScope();
2029
		unitScope.recordQualifiedReference(JAVA_LANG_ASSERTIONERROR);
2022
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ASSERTIONERROR);
2030
		return unitScope.environment.getResolvedType(JAVA_LANG_ASSERTIONERROR, this);
2023
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ASSERTIONERROR, this);
2031
	}
2024
	}
2032
2025
2033
	public final ReferenceBinding getJavaLangClass() {
2026
	public final ReferenceBinding getJavaLangClass() {
2034
		CompilationUnitScope unitScope = compilationUnitScope();
2027
		CompilationUnitScope unitScope = compilationUnitScope();
2035
		unitScope.recordQualifiedReference(JAVA_LANG_CLASS);
2028
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_CLASS);
2036
		return unitScope.environment.getResolvedType(JAVA_LANG_CLASS, this);
2029
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_CLASS, this);
2037
	}
2030
	}
2038
2031
2039
	public final ReferenceBinding getJavaLangCloneable() {
2032
	public final ReferenceBinding getJavaLangCloneable() {
2040
		CompilationUnitScope unitScope = compilationUnitScope();
2033
		CompilationUnitScope unitScope = compilationUnitScope();
2041
		unitScope.recordQualifiedReference(JAVA_LANG_CLONEABLE);
2034
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_CLONEABLE);
2042
		return unitScope.environment.getResolvedType(JAVA_LANG_CLONEABLE, this);
2035
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_CLONEABLE, this);
2043
	}
2036
	}
2044
	public final ReferenceBinding getJavaLangEnum() {
2037
	public final ReferenceBinding getJavaLangEnum() {
2045
		CompilationUnitScope unitScope = compilationUnitScope();
2038
		CompilationUnitScope unitScope = compilationUnitScope();
2046
		unitScope.recordQualifiedReference(JAVA_LANG_ENUM);
2039
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ENUM);
2047
		return unitScope.environment.getResolvedType(JAVA_LANG_ENUM, this);
2040
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ENUM, this);
2048
	}
2041
	}
2049
2042
2050
	public final ReferenceBinding getJavaLangIterable() {
2043
	public final ReferenceBinding getJavaLangIterable() {
2051
		CompilationUnitScope unitScope = compilationUnitScope();
2044
		CompilationUnitScope unitScope = compilationUnitScope();
2052
		unitScope.recordQualifiedReference(JAVA_LANG_ITERABLE);
2045
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ITERABLE);
2053
		return unitScope.environment.getResolvedType(JAVA_LANG_ITERABLE, this);
2046
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ITERABLE, this);
2054
	}
2047
	}
2055
	public final ReferenceBinding getJavaLangObject() {
2048
	public final ReferenceBinding getJavaLangObject() {
2056
		CompilationUnitScope unitScope = compilationUnitScope();
2049
		CompilationUnitScope unitScope = compilationUnitScope();
2057
		unitScope.recordQualifiedReference(JAVA_LANG_OBJECT);
2050
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_OBJECT);
2058
		return unitScope.environment.getResolvedType(JAVA_LANG_OBJECT, this);
2051
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, this);
2059
	}
2052
	}
2060
2053
2061
	public final ReferenceBinding getJavaLangString() {
2054
	public final ReferenceBinding getJavaLangString() {
2062
		CompilationUnitScope unitScope = compilationUnitScope();
2055
		CompilationUnitScope unitScope = compilationUnitScope();
2063
		unitScope.recordQualifiedReference(JAVA_LANG_STRING);
2056
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_STRING);
2064
		return unitScope.environment.getResolvedType(JAVA_LANG_STRING, this);
2057
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_STRING, this);
2065
	}
2058
	}
2066
2059
2067
	public final ReferenceBinding getJavaLangThrowable() {
2060
	public final ReferenceBinding getJavaLangThrowable() {
2068
		CompilationUnitScope unitScope = compilationUnitScope();
2061
		CompilationUnitScope unitScope = compilationUnitScope();
2069
		unitScope.recordQualifiedReference(JAVA_LANG_THROWABLE);
2062
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_THROWABLE);
2070
		return unitScope.environment.getResolvedType(JAVA_LANG_THROWABLE, this);
2063
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_THROWABLE, this);
2071
	}
2064
	}
2072
	public final ReferenceBinding getJavaUtilIterator() {
2065
	public final ReferenceBinding getJavaUtilIterator() {
2073
		CompilationUnitScope unitScope = compilationUnitScope();
2066
		CompilationUnitScope unitScope = compilationUnitScope();
2074
		unitScope.recordQualifiedReference(JAVA_UTIL_ITERATOR);
2067
		unitScope.recordQualifiedReference(TypeConstants.JAVA_UTIL_ITERATOR);
2075
		return unitScope.environment.getResolvedType(JAVA_UTIL_ITERATOR, this);
2068
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_UTIL_ITERATOR, this);
2076
	}
2069
	}
2077
2070
2078
	/* Answer the type binding corresponding to the typeName argument, relative to the enclosingType.
2071
	/* Answer the type binding corresponding to the typeName argument, relative to the enclosingType.
Lines 2114-2120 Link Here
2114
2107
2115
			// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
2108
			// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
2116
			if (argumentTypes == Binding.NO_PARAMETERS
2109
			if (argumentTypes == Binding.NO_PARAMETERS
2117
			    && CharOperation.equals(selector, GETCLASS)
2110
			    && CharOperation.equals(selector, TypeConstants.GETCLASS)
2118
			    && methodBinding.returnType.isParameterizedType()/*1.5*/) {
2111
			    && methodBinding.returnType.isParameterizedType()/*1.5*/) {
2119
					return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
2112
					return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
2120
		    }
2113
		    }
Lines 3038-3045 Link Here
3038
			case 0 : return TypeBinding.VOID;
3031
			case 0 : return TypeBinding.VOID;
3039
			case 1 : return mecs[0];
3032
			case 1 : return mecs[0];
3040
			case 2 :
3033
			case 2 :
3041
				if ((commonDim == 0 ? mecs[1].id : mecs[1].leafComponentType().id) == T_JavaLangObject) return mecs[0];
3034
				if ((commonDim == 0 ? mecs[1].id : mecs[1].leafComponentType().id) == TypeIds.T_JavaLangObject) return mecs[0];
3042
				if ((commonDim == 0 ? mecs[0].id : mecs[0].leafComponentType().id) == T_JavaLangObject) return mecs[1];
3035
				if ((commonDim == 0 ? mecs[0].id : mecs[0].leafComponentType().id) == TypeIds.T_JavaLangObject) return mecs[1];
3043
		}
3036
		}
3044
		TypeBinding[] otherBounds = new TypeBinding[count - 1];
3037
		TypeBinding[] otherBounds = new TypeBinding[count - 1];
3045
		int rank = 0;
3038
		int rank = 0;
Lines 3118-3124 Link Here
3118
			if (dim > 0) {
3111
			if (dim > 0) {
3119
				leafType = typeToVisit.leafComponentType();
3112
				leafType = typeToVisit.leafComponentType();
3120
				switch(leafType.id) {
3113
				switch(leafType.id) {
3121
					case T_JavaLangObject:
3114
					case TypeIds.T_JavaLangObject:
3122
						if (dim > 1) { // Object[][] supertype is Object[]
3115
						if (dim > 1) { // Object[][] supertype is Object[]
3123
							TypeBinding elementType = ((ArrayBinding)typeToVisit).elementsType();
3116
							TypeBinding elementType = ((ArrayBinding)typeToVisit).elementsType();
3124
							if (!typesToVisit.contains(elementType)) {
3117
							if (!typesToVisit.contains(elementType)) {
Lines 3128-3141 Link Here
3128
							continue;
3121
							continue;
3129
						}
3122
						}
3130
						//$FALL-THROUGH$
3123
						//$FALL-THROUGH$
3131
					case T_byte:
3124
					case TypeIds.T_byte:
3132
					case T_short:
3125
					case TypeIds.T_short:
3133
					case T_char:
3126
					case TypeIds.T_char:
3134
					case T_boolean:
3127
					case TypeIds.T_boolean:
3135
					case T_int:
3128
					case TypeIds.T_int:
3136
					case T_long:
3129
					case TypeIds.T_long:
3137
					case T_float:
3130
					case TypeIds.T_float:
3138
					case T_double:
3131
					case TypeIds.T_double:
3139
						TypeBinding superType = getJavaIoSerializable();
3132
						TypeBinding superType = getJavaIoSerializable();
3140
						if (!typesToVisit.contains(superType)) {
3133
						if (!typesToVisit.contains(superType)) {
3141
							typesToVisit.add(superType);
3134
							typesToVisit.add(superType);
Lines 3254-3260 Link Here
3254
				TypeBinding erasedSuperType = erasedSuperTypes[j];
3247
				TypeBinding erasedSuperType = erasedSuperTypes[j];
3255
				if (erasedSuperType == null) continue nextSuperType;
3248
				if (erasedSuperType == null) continue nextSuperType;
3256
				TypeBinding match;
3249
				TypeBinding match;
3257
				if (erasedSuperType == otherType || erasedSuperType.id == T_JavaLangObject && otherType.isInterface()) {
3250
				if (erasedSuperType == otherType || erasedSuperType.id == TypeIds.T_JavaLangObject && otherType.isInterface()) {
3258
					match = erasedSuperType;
3251
					match = erasedSuperType;
3259
				} else {
3252
				} else {
3260
					if (erasedSuperType.isArrayType()) {
3253
					if (erasedSuperType.isArrayType()) {
Lines 3302-3315 Link Here
3302
					TypeBinding otherType = erasedSuperTypes[j];
3295
					TypeBinding otherType = erasedSuperTypes[j];
3303
					if (otherType == null) continue nextOtherType;
3296
					if (otherType == null) continue nextOtherType;
3304
					if (erasedSuperType instanceof ReferenceBinding) {
3297
					if (erasedSuperType instanceof ReferenceBinding) {
3305
						if (otherType.id == T_JavaLangObject && erasedSuperType.isInterface()) continue nextOtherType; // keep Object for an interface
3298
						if (otherType.id == TypeIds.T_JavaLangObject && erasedSuperType.isInterface()) continue nextOtherType; // keep Object for an interface
3306
						if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) {
3299
						if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) {
3307
							erasedSuperTypes[j] = null; // discard non minimal supertype
3300
							erasedSuperTypes[j] = null; // discard non minimal supertype
3308
							remaining--;
3301
							remaining--;
3309
						}
3302
						}
3310
					} else if (erasedSuperType.isArrayType()) {
3303
					} else if (erasedSuperType.isArrayType()) {
3311
					if (otherType.isArrayType() // keep Object[...] for an interface array (same dimensions)
3304
					if (otherType.isArrayType() // keep Object[...] for an interface array (same dimensions)
3312
							&& otherType.leafComponentType().id == T_JavaLangObject
3305
							&& otherType.leafComponentType().id == TypeIds.T_JavaLangObject
3313
							&& otherType.dimensions() == erasedSuperType.dimensions()
3306
							&& otherType.dimensions() == erasedSuperType.dimensions()
3314
							&& erasedSuperType.leafComponentType().isInterface()) continue nextOtherType;
3307
							&& erasedSuperType.leafComponentType().isInterface()) continue nextOtherType;
3315
						if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) {
3308
						if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java (-1 / +15 lines)
Lines 62-67 Link Here
62
	private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4];
62
	private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4];
63
	private MethodVerifier verifier;
63
	private MethodVerifier verifier;
64
64
65
	public MethodBinding arrayClone;
66
	
65
	final static int BUILD_FIELDS_AND_METHODS = 4;
67
	final static int BUILD_FIELDS_AND_METHODS = 4;
66
	final static int BUILD_TYPE_HIERARCHY = 1;
68
	final static int BUILD_TYPE_HIERARCHY = 1;
67
	final static int CHECK_AND_SET_IMPORTS = 2;
69
	final static int CHECK_AND_SET_IMPORTS = 2;
Lines 251-257 Link Here
251
		parsedUnit.scope.buildFieldsAndMethods();
253
		parsedUnit.scope.buildFieldsAndMethods();
252
	this.unitBeingCompleted = null;
254
	this.unitBeingCompleted = null;
253
}
255
}
254
256
public MethodBinding computeArrayClone(MethodBinding objectClone) {
257
	if (this.arrayClone == null) {
258
		this.arrayClone = new MethodBinding(
259
				(objectClone.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic,
260
				TypeConstants.CLONE,
261
				objectClone.returnType,
262
				Binding.NO_PARAMETERS,
263
				Binding.NO_EXCEPTIONS, // no exception for array specific method
264
				(ReferenceBinding)objectClone.returnType);
265
	}
266
	return this.arrayClone;
267
	
268
}
255
public TypeBinding computeBoxingType(TypeBinding type) {
269
public TypeBinding computeBoxingType(TypeBinding type) {
256
	TypeBinding boxedType;
270
	TypeBinding boxedType;
257
	switch (type.id) {
271
	switch (type.id) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java (-7 lines)
Lines 111-117 Link Here
111
	 * Compute the resolved positions for all the synthetic arguments
111
	 * Compute the resolved positions for all the synthetic arguments
112
	 */
112
	 */
113
	final public void computeSyntheticArgumentSlotSizes() {
113
	final public void computeSyntheticArgumentSlotSizes() {
114
115
		int slotSize = 0;
114
		int slotSize = 0;
116
		// insert enclosing instances first, followed by the outerLocals
115
		// insert enclosing instances first, followed by the outerLocals
117
		int enclosingInstancesCount = this.enclosingInstances == null ? 0 : this.enclosingInstances.length;
116
		int enclosingInstancesCount = this.enclosingInstances == null ? 0 : this.enclosingInstances.length;
Lines 147-162 Link Here
147
	/* Answer the receiver's enclosing type... null if the receiver is a top level type.
146
	/* Answer the receiver's enclosing type... null if the receiver is a top level type.
148
	*/
147
	*/
149
	public ReferenceBinding enclosingType() {
148
	public ReferenceBinding enclosingType() {
150
151
		return this.enclosingType;
149
		return this.enclosingType;
152
	}
150
	}
153
151
154
	/* Answer the synthetic argument for <actualOuterLocalVariable> or null if one does not exist.
152
	/* Answer the synthetic argument for <actualOuterLocalVariable> or null if one does not exist.
155
	*/
153
	*/
156
	public SyntheticArgumentBinding getSyntheticArgument(LocalVariableBinding actualOuterLocalVariable) {
154
	public SyntheticArgumentBinding getSyntheticArgument(LocalVariableBinding actualOuterLocalVariable) {
157
158
		if (this.outerLocalVariables == null) return null;		// is null if no outer local variables are known
155
		if (this.outerLocalVariables == null) return null;		// is null if no outer local variables are known
159
160
		for (int i = this.outerLocalVariables.length; --i >= 0;)
156
		for (int i = this.outerLocalVariables.length; --i >= 0;)
161
			if (this.outerLocalVariables[i].actualOuterLocalVariable == actualOuterLocalVariable)
157
			if (this.outerLocalVariables[i].actualOuterLocalVariable == actualOuterLocalVariable)
162
				return this.outerLocalVariables[i];
158
				return this.outerLocalVariables[i];
Lines 170-176 Link Here
170
	public ReferenceBinding[] syntheticEnclosingInstanceTypes() {
166
	public ReferenceBinding[] syntheticEnclosingInstanceTypes() {
171
		if (this.enclosingInstances == null)
167
		if (this.enclosingInstances == null)
172
			return null;
168
			return null;
173
174
		int length = this.enclosingInstances.length;
169
		int length = this.enclosingInstances.length;
175
		ReferenceBinding types[] = new ReferenceBinding[length];
170
		ReferenceBinding types[] = new ReferenceBinding[length];
176
		for (int i = 0; i < length; i++)
171
		for (int i = 0; i < length; i++)
Lines 194-202 Link Here
194
	/* Answer the synthetic argument for <targetEnclosingType> or null if one does not exist.
189
	/* Answer the synthetic argument for <targetEnclosingType> or null if one does not exist.
195
	*/
190
	*/
196
	public SyntheticArgumentBinding getSyntheticArgument(ReferenceBinding targetEnclosingType, boolean onlyExactMatch) {
191
	public SyntheticArgumentBinding getSyntheticArgument(ReferenceBinding targetEnclosingType, boolean onlyExactMatch) {
197
198
		if (this.enclosingInstances == null) return null;		// is null if no enclosing instances are known
192
		if (this.enclosingInstances == null) return null;		// is null if no enclosing instances are known
199
200
		// exact match
193
		// exact match
201
		for (int i = this.enclosingInstances.length; --i >= 0;)
194
		for (int i = this.enclosingInstances.length; --i >= 0;)
202
			if (this.enclosingInstances[i].type == targetEnclosingType)
195
			if (this.enclosingInstances[i].type == targetEnclosingType)
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java (+151 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
import java.io.File;
12
import java.io.File;
13
import java.util.Map;
13
14
14
import junit.framework.Test;
15
import junit.framework.Test;
15
16
Lines 393-396 Link Here
393
		"argument cannot be resolved\n" +
394
		"argument cannot be resolved\n" +
394
		"----------\n");
395
		"----------\n");
395
}
396
}
397
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307
398
// Check return type of array#clone()
399
public void test014() throws Exception {
400
	Map optionsMap = getCompilerOptions();
401
	CompilerOptions options = new CompilerOptions(optionsMap);
402
	if (options.complianceLevel > ClassFileConstants.JDK1_4) {
403
		// check that #clone() return type is changed ONLY from -source 1.5 only (independant from compliance level)
404
		optionsMap.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);		
405
	}	
406
	this.runNegativeTest(
407
			new String[] {
408
				"X.java",
409
				"public class X {\n" + 
410
				"	void foo(long[] longs) throws Exception {\n" + 
411
				"		long[] other = longs.clone();\n" + 
412
				"	}\n" + 
413
				"}\n",
414
			},
415
			"----------\n" + 
416
			"1. ERROR in X.java (at line 3)\n" + 
417
			"	long[] other = longs.clone();\n" + 
418
			"	               ^^^^^^^^^^^^^\n" + 
419
			"Type mismatch: cannot convert from Object to long[]\n" + 
420
			"----------\n",
421
			null,
422
			true,
423
			optionsMap);
424
}
425
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation
426
//Check return type of array#clone()
427
public void test015() throws Exception {
428
	if ( new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_5) {
429
		return;
430
	}
431
	this.runConformTest(
432
		new String[] {
433
			"X.java",
434
			"public class X {\n" + 
435
			"	void foo(long[] longs) throws Exception {\n" + 
436
			"		long[] other = longs.clone();\n" + 
437
			"	}\n" + 
438
			"}\n",
439
		},
440
		"");
441
}
442
//https:bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation
443
//Check constant pool declaring class of array#clone()
444
public void test016() throws Exception {
445
	this.runConformTest(
446
			new String[] {
447
				"X.java",
448
				"public class X {\n" + 
449
				"	void foo(long[] longs) throws Exception {\n" + 
450
				"		Object other = longs.clone();\n" + 
451
				"	}\n" + 
452
				"}\n",
453
			},
454
			"");
455
	ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
456
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator  +"X.class"));
457
	String actualOutput =
458
		disassembler.disassemble(
459
			classFileBytes,
460
			"\n",
461
			ClassFileBytesDisassembler.DETAILED);
462
463
	String expectedOutput =	new CompilerOptions(getCompilerOptions()).sourceLevel <= ClassFileConstants.JDK1_4
464
		?	"  // Method descriptor #15 ([J)V\n" + 
465
			"  // Stack: 1, Locals: 3\n" + 
466
			"  void foo(long[] longs) throws java.lang.Exception;\n" + 
467
			"    0  aload_1 [longs]\n" + 
468
			"    1  invokevirtual java.lang.Object.clone() : java.lang.Object [19]\n" + 
469
			"    4  astore_2 [other]\n" + 
470
			"    5  return\n" + 
471
			"      Line numbers:\n" + 
472
			"        [pc: 0, line: 3]\n" + 
473
			"        [pc: 5, line: 4]\n"
474
		:	"  // Method descriptor #15 ([J)V\n" + 
475
			"  // Stack: 1, Locals: 3\n" + 
476
			"  void foo(long[] longs) throws java.lang.Exception;\n" + 
477
			"    0  aload_1 [longs]\n" + 
478
			"    1  invokevirtual long[].clone() : java.lang.Object [19]\n" + 
479
			"    4  astore_2 [other]\n" + 
480
			"    5  return\n" + 
481
			"      Line numbers:\n" + 
482
			"        [pc: 0, line: 3]\n" + 
483
			"        [pc: 5, line: 4]\n";
484
485
	int index = actualOutput.indexOf(expectedOutput);
486
	if (index == -1 || expectedOutput.length() == 0) {
487
		System.out.println(Util.displayString(actualOutput, 3));
488
	}
489
	if (index == -1) {
490
		assertEquals("unexpected bytecode sequence", expectedOutput, actualOutput);
491
	}		
492
	return;
493
}
494
495
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation
496
//Check constant pool declaring class of array#clone()
497
public void test017() throws Exception {
498
	Map optionsMap = getCompilerOptions();
499
	CompilerOptions options = new CompilerOptions(optionsMap);
500
	if (options.complianceLevel > ClassFileConstants.JDK1_4) {
501
		// check that #clone() return type is changed ONLY from -source 1.5 only (independant from compliance level)
502
		optionsMap.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);		
503
	}
504
	this.runConformTest(
505
			new String[] {
506
				"X.java",
507
				"public class X {\n" + 
508
				"	void foo(long[] longs) throws Exception {\n" + 
509
				"		Object other = longs.clone();\n" + 
510
				"	}\n" + 
511
				"}\n",
512
			},
513
			"",
514
			null,
515
			true,
516
			null,
517
			optionsMap,
518
			null);
519
	ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
520
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator  +"X.class"));
521
	String actualOutput =
522
		disassembler.disassemble(
523
			classFileBytes,
524
			"\n",
525
			ClassFileBytesDisassembler.DETAILED);
526
527
	String expectedOutput =
528
		"  // Method descriptor #15 ([J)V\n" + 
529
		"  // Stack: 1, Locals: 3\n" + 
530
		"  void foo(long[] longs) throws java.lang.Exception;\n" + 
531
		"    0  aload_1 [longs]\n" + 
532
		"    1  invokevirtual java.lang.Object.clone() : java.lang.Object [19]\n" + 
533
		"    4  astore_2 [other]\n" + 
534
		"    5  return\n" + 
535
		"      Line numbers:\n" + 
536
		"        [pc: 0, line: 3]\n" + 
537
		"        [pc: 5, line: 4]\n";
538
539
	int index = actualOutput.indexOf(expectedOutput);
540
	if (index == -1 || expectedOutput.length() == 0) {
541
		System.out.println(Util.displayString(actualOutput, 3));
542
	}
543
	if (index == -1) {
544
		assertEquals("unexpected bytecode sequence", expectedOutput, actualOutput);
545
	}		
546
}
396
}
547
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java (-2 / +3 lines)
Lines 1423-1430 Link Here
1423
			"\n",
1423
			"\n",
1424
			ClassFileBytesDisassembler.DETAILED);
1424
			ClassFileBytesDisassembler.DETAILED);
1425
1425
1426
	String expectedOutput =
1426
	String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel <= ClassFileConstants.JDK1_4
1427
		"     1  invokevirtual java.lang.String[].clone() : java.lang.Object [16]\n";
1427
		?	"     1  invokevirtual java.lang.Object.clone() : java.lang.Object [16]\n"
1428
		:	"     1  invokevirtual java.lang.String[].clone() : java.lang.Object [16]\n";
1428
1429
1429
	int index = actualOutput.indexOf(expectedOutput);
1430
	int index = actualOutput.indexOf(expectedOutput);
1430
	if (index == -1 || expectedOutput.length() == 0) {
1431
	if (index == -1 || expectedOutput.length() == 0) {

Return to bug 247292