View | Details | Raw Unified | Return to bug 147690
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java (+59 lines)
Lines 10-18 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
12
13
import java.io.File;
14
import java.io.IOException;
13
import java.util.Map;
15
import java.util.Map;
14
16
15
import junit.framework.*;
17
import junit.framework.*;
18
19
import org.eclipse.jdt.core.ToolFactory;
20
import org.eclipse.jdt.core.tests.util.Util;
21
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
16
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
22
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
17
23
18
public class MethodVerifyTest extends AbstractComparableTest {
24
public class MethodVerifyTest extends AbstractComparableTest {
Lines 5114-5117 Link Here
5114
			"----------\n"
5120
			"----------\n"
5115
		);
5121
		);
5116
	}
5122
	}
5123
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=147690
5124
	public void testONLY_090() {
5125
		this.runConformTest(
5126
			new String[] {
5127
				"X.java",
5128
				"class XSuper {\n" + 
5129
				"	Object foo() throws Exception { return null; }\n" + 
5130
				"	protected Object bar() throws Exception { return null; }\n" + 
5131
				"}\n" + 
5132
				"public class X extends XSuper {\n" + 
5133
				"	protected String foo() { return null; }\n" + 
5134
				"	public String bar() { return null; }\n" + 
5135
				"}", // =================
5136
			},
5137
			"");
5138
		// 	ensure bridge methods have target method modifiers, and inherited thrown exceptions
5139
		String expectedOutput =
5140
			"  // Method descriptor #17 ()Ljava/lang/Object;\n" + 
5141
			"  // Stack: 1, Locals: 1\n" + 
5142
			"  public bridge synthetic java.lang.Object bar() throws java.lang.Exception;\n" + 
5143
			"    0  aload_0\n" + 
5144
			"    1  invokevirtual X.bar() : java.lang.String [21]\n" + 
5145
			"    4  areturn\n" + 
5146
			"      Line numbers:\n" + 
5147
			"        [pc: 0, line: 1]\n" + 
5148
			"  \n" + 
5149
			"  // Method descriptor #17 ()Ljava/lang/Object;\n" + 
5150
			"  // Stack: 1, Locals: 1\n" + 
5151
			"  protected bridge synthetic java.lang.Object foo() throws java.lang.Exception;\n" + 
5152
			"    0  aload_0\n" + 
5153
			"    1  invokevirtual X.foo() : java.lang.String [23]\n" + 
5154
			"    4  areturn\n" + 
5155
			"      Line numbers:\n" + 
5156
			"        [pc: 0, line: 1]\n";
5157
		
5158
		try {
5159
			File f = new File(OUTPUT_DIR + File.separator + "X.class");
5160
			byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
5161
			ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
5162
			String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
5163
			int index = result.indexOf(expectedOutput);
5164
			if (index == -1 || expectedOutput.length() == 0) {
5165
				System.out.println(Util.displayString(result, 3));
5166
			}
5167
			if (index == -1) {
5168
				assertEquals("Wrong contents", expectedOutput, result);
5169
			}
5170
		} catch (org.eclipse.jdt.core.util.ClassFormatException e) {
5171
			assertTrue(false);
5172
		} catch (IOException e) {
5173
			assertTrue(false);
5174
		}		
5175
	}	
5117
}
5176
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java (-1 / +2 lines)
Lines 223-229 Link Here
223
	    this.declaringClass = declaringClass;
223
	    this.declaringClass = declaringClass;
224
	    this.selector = overridenMethodToBridge.selector;
224
	    this.selector = overridenMethodToBridge.selector;
225
	    // amongst other, clear the AccGenericSignature, so as to ensure no remains of original inherited persist (101794)
225
	    // amongst other, clear the AccGenericSignature, so as to ensure no remains of original inherited persist (101794)
226
	    this.modifiers = (overridenMethodToBridge.modifiers | ClassFileConstants.AccBridge | ClassFileConstants.AccSynthetic) & ~(ClassFileConstants.AccAbstract | ClassFileConstants.AccNative | ExtraCompilerModifiers.AccGenericSignature);
226
	    // also use the modifiers from the target method, as opposed to inherited one (147690)
227
	    this.modifiers = (targetMethod.modifiers | ClassFileConstants.AccBridge | ClassFileConstants.AccSynthetic) & ~(ClassFileConstants.AccAbstract | ClassFileConstants.AccNative | ExtraCompilerModifiers.AccGenericSignature);
227
		this.tagBits |= TagBits.AnnotationResolved;
228
		this.tagBits |= TagBits.AnnotationResolved;
228
	    this.returnType = overridenMethodToBridge.returnType;
229
	    this.returnType = overridenMethodToBridge.returnType;
229
	    this.parameters = overridenMethodToBridge.parameters;
230
	    this.parameters = overridenMethodToBridge.parameters;

Return to bug 147690