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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java (-1 / +1 lines)
Lines 40-46 Link Here
40
		// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=22334
40
		// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=22334
41
		if (!sourceType.isInterface()
41
		if (!sourceType.isInterface()
42
				&& !this.targetType.isBaseType()
42
				&& !this.targetType.isBaseType()
43
				&& currentScope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5) {
43
				&& currentScope.compilerOptions().targetJDK < ClassFileConstants.JDK1_5) {
44
			this.syntheticField = sourceType.addSyntheticFieldForClassLiteral(this.targetType, currentScope);
44
			this.syntheticField = sourceType.addSyntheticFieldForClassLiteral(this.targetType, currentScope);
45
		}
45
		}
46
		return flowInfo;
46
		return flowInfo;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/Jsr14Test.java (+81 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 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.core.tests.compiler.regression;
12
13
import java.io.File;
14
import java.util.Map;
15
16
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
17
18
import junit.framework.Test;
19
20
public class Jsr14Test extends AbstractRegressionTest {
21
22
public Jsr14Test(String name) {
23
	super(name);
24
}
25
protected Map getCompilerOptions() {
26
	Map options = super.getCompilerOptions();
27
	options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
28
	options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
29
	options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
30
	return options;
31
}
32
// Static initializer to specify tests subset using TESTS_* static variables
33
// All specified tests which does not belong to the class are skipped...
34
static {
35
//	TESTS_NAMES = new String[] { "test000" };
36
//	TESTS_NUMBERS = new int[] { 15 };
37
//	TESTS_RANGE = new int[] { 11, -1 };
38
}
39
public static Test suite() {
40
	return buildMinimalComplianceTestSuite(testClass(), F_1_4);
41
}
42
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=277450
43
public void test1() throws Exception {
44
	this.runConformTest(
45
		new String[] {
46
			"X.java",
47
			"public class X {\n" + 
48
			"	public static void main(String[] args) {\n" + 
49
			"		System.out.println(X.class);\n" + 
50
			"	}\n" + 
51
			"}",
52
		},
53
		"class X");
54
	String expectedOutput =
55
		"  // Method descriptor #18 ([Ljava/lang/String;)V\n" + 
56
		"  // Stack: 3, Locals: 1\n" + 
57
		"  public static void main(java.lang.String[] args);\n" + 
58
		"     0  getstatic java.lang.System.out : java.io.PrintStream [19]\n" + 
59
		"     3  getstatic X.class$0 : java.lang.Class [25]\n" + 
60
		"     6  dup\n" + 
61
		"     7  ifnonnull 35\n" + 
62
		"    10  pop\n" + 
63
		"    11  ldc <String \"X\"> [27]\n" + 
64
		"    13  invokestatic java.lang.Class.forName(java.lang.String) : java.lang.Class [28]\n" + 
65
		"    16  dup\n" + 
66
		"    17  putstatic X.class$0 : java.lang.Class [25]\n" + 
67
		"    20  goto 35\n" + 
68
		"    23  new java.lang.NoClassDefFoundError [34]\n" + 
69
		"    26  dup_x1\n" + 
70
		"    27  swap\n" + 
71
		"    28  invokevirtual java.lang.Throwable.getMessage() : java.lang.String [36]\n" + 
72
		"    31  invokespecial java.lang.NoClassDefFoundError(java.lang.String) [42]\n" + 
73
		"    34  athrow\n" + 
74
		"    35  invokevirtual java.io.PrintStream.println(java.lang.Object) : void [45]\n" + 
75
		"    38  return\n";
76
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
77
}
78
public static Class testClass() {
79
	return Jsr14Test.class;
80
}
81
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java (+1 lines)
Lines 172-177 Link Here
172
		TestCase.RUN_ONLY_ID = null;
172
		TestCase.RUN_ONLY_ID = null;
173
		all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_7, tests_1_7));
173
		all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_7, tests_1_7));
174
	}
174
	}
175
	all.addTest(new TestSuite(Jsr14Test.class));
175
	return all;
176
	return all;
176
}
177
}
177
}
178
}

Return to bug 323012