Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 428178
Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava8Tests.java (+2 lines)
Lines 39-42 Link Here
39
import org.eclipse.jdt.core.tests.formatter.FormatterJSR335Tests;
39
import org.eclipse.jdt.core.tests.formatter.FormatterJSR335Tests;
40
import org.eclipse.jdt.core.tests.model.CompletionTests18;
40
import org.eclipse.jdt.core.tests.model.CompletionTests18;
41
import org.eclipse.jdt.core.tests.model.JavaElement8Tests;
41
import org.eclipse.jdt.core.tests.model.JavaSearchBugs8Tests;
42
import org.eclipse.jdt.core.tests.model.JavaSearchBugs8Tests;
42
import org.eclipse.jdt.core.tests.model.ResolveTests18;
43
import org.eclipse.jdt.core.tests.model.ResolveTests18;
Lines 60-63 Link Here
60
			IncrementalTests18.class,
61
			IncrementalTests18.class,
61
			org.eclipse.jdt.compiler.apt.tests.AllTests.class,
62
			org.eclipse.jdt.compiler.apt.tests.AllTests.class,
63
			JavaElement8Tests.class,
62
		};
64
		};
63
	}
65
	}
(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java (-1 / +7 lines)
Lines 1-8 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2012 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
7
 *
11
 *
8
 * Contributors:
12
 * Contributors:
Lines 193-196 Link Here
193
		// Tests regarding null-annotations:
197
		// Tests regarding null-annotations:
194
		NullAnnotationModelTests.class,
198
		NullAnnotationModelTests.class,
199
		// Java model changes related to Java 8
200
		JavaElement8Tests.class,
195
	};
201
	};
196
202
(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElement8Tests.java (+91 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2014 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
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 * 
12
 * Contributors:
13
 *     IBM Corporation - initial API and implementation
14
 *******************************************************************************/
15
package org.eclipse.jdt.core.tests.model;
16
17
import junit.framework.Test;
18
import junit.framework.TestSuite;
19
20
import org.eclipse.jdt.core.ICompilationUnit;
21
import org.eclipse.jdt.core.IJavaProject;
22
import org.eclipse.jdt.core.IMethod;
23
import org.eclipse.jdt.core.IType;
24
import org.eclipse.jdt.core.JavaCore;
25
26
public class JavaElement8Tests extends AbstractJavaModelTests { 
27
28
	static {
29
//		TESTS_NAMES = new String[] {"testBug428178"};
30
	}
31
32
	public JavaElement8Tests(String name) {
33
		super(name);
34
		this.endChar = "";
35
	}
36
	public static Test suite() {
37
		if (TESTS_PREFIX != null || TESTS_NAMES != null || TESTS_NUMBERS!=null || TESTS_RANGE !=null) {
38
			return buildModelTestSuite(JavaElement8Tests.class);
39
		}
40
		TestSuite suite = new Suite(JavaElement8Tests.class.getName());
41
		suite.addTest(new JavaElement8Tests("testBug428178"));
42
		suite.addTest(new JavaElement8Tests("testBug428178a"));
43
		return suite;
44
	}
45
	public void testBug428178() throws Exception {
46
		try {
47
			IJavaProject project = createJavaProject("Bug428178", new String[] {"src"}, new String[] {"JCL18_FULL"}, "bin", "1.8");
48
			project.open(null);
49
				String fileContent =  "package p;\n" +
50
						 "public interface Test {\n" +
51
						 "	static void main(String[] args) {\n" +
52
						 "		System.out.println(\"Hello\");\n" +
53
						 "	}\n" +
54
						 "}";
55
				createFolder("/Bug428178/src/p");
56
				createFile(	"/Bug428178/src/p/Test.java",	fileContent);
57
58
				ICompilationUnit unit = getCompilationUnit("/Bug428178/src/p/Test.java");
59
				IMethod method = unit.getTypes()[0].getMethods()[0];
60
				assertNotNull("Method should not be null", method);
61
				assertTrue("Should be a main method", method.isMainMethod());
62
		}
63
		finally {
64
			deleteProject("Bug428178");
65
		}
66
	}
67
	public void testBug428178a() throws Exception {
68
		try {
69
			IJavaProject project = createJavaProject("Bug428178", new String[] {"src"}, new String[] {"JCL18_FULL"}, "bin", "1.8");
70
			project.open(null);
71
			String fileContent =  "package p;\n" +
72
					 "public interface Test {\n" +
73
					 "	static void main(String[] args) {\n" +
74
					 "		System.out.println(\"Hello\");\n" +
75
					 "	}\n" +
76
					 "}";
77
			addLibrary(project, 
78
							"lib.jar", 
79
							"src.zip", new 
80
							String[] {"p/Test.java", fileContent},
81
							JavaCore.VERSION_1_8);
82
				IType type = getPackageFragmentRoot("Bug428178", "lib.jar").getPackageFragment("p").getClassFile("Test.class").getType();
83
				IMethod method = type.getMethods()[0];
84
				assertNotNull("Method should not be null", method);
85
				assertTrue("Should be a main method", method.isMainMethod());
86
		}
87
		finally {
88
			deleteProject("Bug428178");
89
		}
90
	}
91
}
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java (-2 / +9 lines)
Lines 1-8 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2013 IBM Corporation and others.
2
 * Copyright (c) 2000, 2014 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
7
 *
11
 *
8
 * Contributors:
12
 * Contributors:
Lines 357-361 Link Here
357
	if ("main".equals(method.getElementName()) && Signature.SIG_VOID.equals(method.getReturnType())) { //$NON-NLS-1$
361
	if ("main".equals(method.getElementName()) && Signature.SIG_VOID.equals(method.getReturnType())) { //$NON-NLS-1$
358
		int flags= method.getFlags();
362
		int flags= method.getFlags();
359
		if (Flags.isStatic(flags) && Flags.isPublic(flags)) {
363
		IType declaringType = null;
364
		if (Flags.isStatic(flags) &&
365
				(Flags.isPublic(flags) || 
366
						((declaringType = getDeclaringType()) != null && declaringType.isInterface()))) {
360
			String[] paramTypes= method.getParameterTypes();
367
			String[] paramTypes= method.getParameterTypes();
361
			if (paramTypes.length == 1) {
368
			if (paramTypes.length == 1) {

Return to bug 428178