Lines 1237-1242
Link Here
|
1237 |
// generate a method info to define <enum>#valueOf(String) |
1237 |
// generate a method info to define <enum>#valueOf(String) |
1238 |
addSyntheticEnumValueOfMethod(syntheticMethod); |
1238 |
addSyntheticEnumValueOfMethod(syntheticMethod); |
1239 |
break; |
1239 |
break; |
|
|
1240 |
case SyntheticMethodBinding.SwitchTable : |
1241 |
// generate a method info to define the switch table synthetic method |
1242 |
addSyntheticSwitchTable(syntheticMethod); |
1240 |
} |
1243 |
} |
1241 |
} |
1244 |
} |
1242 |
} |
1245 |
} |
Lines 1316-1321
Link Here
|
1316 |
|
1319 |
|
1317 |
} |
1320 |
} |
1318 |
|
1321 |
|
|
|
1322 |
public void addSyntheticSwitchTable(SyntheticMethodBinding methodBinding) { |
1323 |
generateMethodInfoHeader(methodBinding); |
1324 |
// We know that we won't get more than 1 attribute: the code attribute |
1325 |
contents[contentsOffset++] = 0; |
1326 |
contents[contentsOffset++] = 2; |
1327 |
// Code attribute |
1328 |
int codeAttributeOffset = contentsOffset; |
1329 |
generateCodeAttributeHeader(); |
1330 |
codeStream.init(this); |
1331 |
codeStream.generateSyntheticBodyForSwitchTable(methodBinding); |
1332 |
completeCodeAttributeForSyntheticMethod( |
1333 |
true, |
1334 |
methodBinding, |
1335 |
codeAttributeOffset, |
1336 |
((SourceTypeBinding) methodBinding.declaringClass) |
1337 |
.scope |
1338 |
.referenceCompilationUnit() |
1339 |
.compilationResult |
1340 |
.lineSeparatorPositions); |
1341 |
// add the synthetic attribute |
1342 |
int syntheticAttributeNameIndex = |
1343 |
constantPool.literalIndex(AttributeNamesConstants.SyntheticName); |
1344 |
contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8); |
1345 |
contents[contentsOffset++] = (byte) syntheticAttributeNameIndex; |
1346 |
// the length of a synthetic attribute is equals to 0 |
1347 |
contents[contentsOffset++] = 0; |
1348 |
contents[contentsOffset++] = 0; |
1349 |
contents[contentsOffset++] = 0; |
1350 |
contents[contentsOffset++] = 0; |
1351 |
} |
1319 |
/** |
1352 |
/** |
1320 |
* INTERNAL USE-ONLY |
1353 |
* INTERNAL USE-ONLY |
1321 |
* Generate the bytes for a synthetic method that implements Enum#values() for a given enum type |
1354 |
* Generate the bytes for a synthetic method that implements Enum#values() for a given enum type |
Lines 2575-2580
Link Here
|
2575 |
SyntheticMethodBinding binding, |
2608 |
SyntheticMethodBinding binding, |
2576 |
int codeAttributeOffset, |
2609 |
int codeAttributeOffset, |
2577 |
int[] startLineIndexes) { |
2610 |
int[] startLineIndexes) { |
|
|
2611 |
|
2612 |
this.completeCodeAttributeForSyntheticMethod( |
2613 |
false, |
2614 |
binding, |
2615 |
codeAttributeOffset, |
2616 |
startLineIndexes); |
2617 |
} |
2618 |
|
2619 |
/** |
2620 |
* INTERNAL USE-ONLY |
2621 |
* That method completes the creation of the code attribute by setting |
2622 |
* - the attribute_length |
2623 |
* - max_stack |
2624 |
* - max_locals |
2625 |
* - code_length |
2626 |
* - exception table |
2627 |
* - and debug attributes if necessary. |
2628 |
* |
2629 |
* @param binding org.eclipse.jdt.internal.compiler.lookup.SyntheticAccessMethodBinding |
2630 |
* @param codeAttributeOffset <CODE>int</CODE> |
2631 |
*/ |
2632 |
public void completeCodeAttributeForSyntheticMethod( |
2633 |
boolean hasExceptionHandlers, |
2634 |
SyntheticMethodBinding binding, |
2635 |
int codeAttributeOffset, |
2636 |
int[] startLineIndexes) { |
2578 |
// reinitialize the contents with the byte modified by the code stream |
2637 |
// reinitialize the contents with the byte modified by the code stream |
2579 |
this.contents = codeStream.bCodeStream; |
2638 |
this.contents = codeStream.bCodeStream; |
2580 |
int localContentsOffset = codeStream.classFileOffset; |
2639 |
int localContentsOffset = codeStream.classFileOffset; |
Lines 2596-2605
Link Here
|
2596 |
if ((localContentsOffset + 40) >= this.contents.length) { |
2655 |
if ((localContentsOffset + 40) >= this.contents.length) { |
2597 |
resizeContents(40); |
2656 |
resizeContents(40); |
2598 |
} |
2657 |
} |
2599 |
// there is no exception table, so we need to offset by 2 the current offset and move |
2658 |
|
2600 |
// on the attribute generation |
2659 |
if (hasExceptionHandlers) { |
2601 |
contents[localContentsOffset++] = 0; |
2660 |
// write the exception table |
2602 |
contents[localContentsOffset++] = 0; |
2661 |
int exceptionHandlersNumber = codeStream.exceptionHandlersCounter; |
|
|
2662 |
ExceptionLabel[] exceptionHandlers = codeStream.exceptionHandlers; |
2663 |
int exSize = exceptionHandlersNumber * 8 + 2; |
2664 |
if (exSize + localContentsOffset >= this.contents.length) { |
2665 |
resizeContents(exSize); |
2666 |
} |
2667 |
// there is no exception table, so we need to offset by 2 the current offset and move |
2668 |
// on the attribute generation |
2669 |
this.contents[localContentsOffset++] = (byte) (exceptionHandlersNumber >> 8); |
2670 |
this.contents[localContentsOffset++] = (byte) exceptionHandlersNumber; |
2671 |
for (int i = 0, max = codeStream.exceptionHandlersIndex; i < max; i++) { |
2672 |
ExceptionLabel exceptionHandler = exceptionHandlers[i]; |
2673 |
if (exceptionHandler != null) { |
2674 |
int start = exceptionHandler.start; |
2675 |
this.contents[localContentsOffset++] = (byte) (start >> 8); |
2676 |
this.contents[localContentsOffset++] = (byte) start; |
2677 |
int end = exceptionHandler.end; |
2678 |
this.contents[localContentsOffset++] = (byte) (end >> 8); |
2679 |
this.contents[localContentsOffset++] = (byte) end; |
2680 |
int handlerPC = exceptionHandler.position; |
2681 |
this.contents[localContentsOffset++] = (byte) (handlerPC >> 8); |
2682 |
this.contents[localContentsOffset++] = (byte) handlerPC; |
2683 |
if (exceptionHandler.exceptionType == null) { |
2684 |
// any exception handler |
2685 |
this.contents[localContentsOffset++] = 0; |
2686 |
this.contents[localContentsOffset++] = 0; |
2687 |
} else { |
2688 |
int nameIndex; |
2689 |
switch(exceptionHandler.exceptionType.id) { |
2690 |
case T_null : |
2691 |
/* represents ClassNotFoundException, see class literal access*/ |
2692 |
nameIndex = constantPool.literalIndexForType(ConstantPool.JavaLangClassNotFoundExceptionConstantPoolName); |
2693 |
break; |
2694 |
case T_long : |
2695 |
/* represents NoSuchFieldError, see switch table generation*/ |
2696 |
nameIndex = constantPool.literalIndexForType(ConstantPool.JavaLangNoSuchFieldErrorConstantPoolName); |
2697 |
break; |
2698 |
default: |
2699 |
nameIndex = constantPool.literalIndexForType(exceptionHandler.exceptionType.constantPoolName()); |
2700 |
} |
2701 |
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8); |
2702 |
this.contents[localContentsOffset++] = (byte) nameIndex; |
2703 |
} |
2704 |
} |
2705 |
} |
2706 |
} else { |
2707 |
// there is no exception table, so we need to offset by 2 the current offset and move |
2708 |
// on the attribute generation |
2709 |
contents[localContentsOffset++] = 0; |
2710 |
contents[localContentsOffset++] = 0; |
2711 |
} |
2603 |
// debug attributes |
2712 |
// debug attributes |
2604 |
int codeAttributeAttributeOffset = localContentsOffset; |
2713 |
int codeAttributeAttributeOffset = localContentsOffset; |
2605 |
int attributeNumber = 0; |
2714 |
int attributeNumber = 0; |
Lines 2769-2775
Link Here
|
2769 |
contents[codeAttributeOffset + 5] = (byte) codeAttributeLength; |
2878 |
contents[codeAttributeOffset + 5] = (byte) codeAttributeLength; |
2770 |
contentsOffset = localContentsOffset; |
2879 |
contentsOffset = localContentsOffset; |
2771 |
} |
2880 |
} |
2772 |
|
2881 |
|
2773 |
/** |
2882 |
/** |
2774 |
* INTERNAL USE-ONLY |
2883 |
* INTERNAL USE-ONLY |
2775 |
* Complete the creation of a method info by setting up the number of attributes at the right offset. |
2884 |
* Complete the creation of a method info by setting up the number of attributes at the right offset. |