Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 239952 Details for
Bug 428178
[1.8] isMainMethod(IMethod) should consider the default Public modifier for main method in interface
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix with tests
Bug-428178.patch (text/plain), 7.45 KB, created by
Jay Arthanareeswaran
on 2014-02-14 07:51:50 EST
(
hide
)
Description:
Fix with tests
Filename:
MIME Type:
Creator:
Jay Arthanareeswaran
Created:
2014-02-14 07:51:50 EST
Size:
7.45 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava8Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava8Tests.java >index 4fcf2be..fb6b63c 100644 >--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava8Tests.java >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava8Tests.java >@@ -39,4 +39,5 @@ > import org.eclipse.jdt.core.tests.formatter.FormatterJSR335Tests; > import org.eclipse.jdt.core.tests.model.CompletionTests18; >+import org.eclipse.jdt.core.tests.model.JavaElement8Tests; > import org.eclipse.jdt.core.tests.model.JavaSearchBugs8Tests; > import org.eclipse.jdt.core.tests.model.ResolveTests18; >@@ -60,4 +61,5 @@ > IncrementalTests18.class, > org.eclipse.jdt.compiler.apt.tests.AllTests.class, >+ JavaElement8Tests.class, > }; > } >diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java >index b309072..5523716 100644 >--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java >@@ -1,8 +1,12 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2012 IBM Corporation and others. >+ * Copyright (c) 2000, 2014 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. > * > * Contributors: >@@ -193,4 +197,6 @@ > // Tests regarding null-annotations: > NullAnnotationModelTests.class, >+ // Java model changes related to Java 8 >+ JavaElement8Tests.class, > }; > >diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElement8Tests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElement8Tests.java >new file mode 100644 >index 0000000..9d8678c >--- /dev/null >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElement8Tests.java >@@ -0,0 +1,91 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2014 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests.model; >+ >+import junit.framework.Test; >+import junit.framework.TestSuite; >+ >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaCore; >+ >+public class JavaElement8Tests extends AbstractJavaModelTests { >+ >+ static { >+// TESTS_NAMES = new String[] {"testBug428178"}; >+ } >+ >+ public JavaElement8Tests(String name) { >+ super(name); >+ this.endChar = ""; >+ } >+ public static Test suite() { >+ if (TESTS_PREFIX != null || TESTS_NAMES != null || TESTS_NUMBERS!=null || TESTS_RANGE !=null) { >+ return buildModelTestSuite(JavaElement8Tests.class); >+ } >+ TestSuite suite = new Suite(JavaElement8Tests.class.getName()); >+ suite.addTest(new JavaElement8Tests("testBug428178")); >+ suite.addTest(new JavaElement8Tests("testBug428178a")); >+ return suite; >+ } >+ public void testBug428178() throws Exception { >+ try { >+ IJavaProject project = createJavaProject("Bug428178", new String[] {"src"}, new String[] {"JCL18_FULL"}, "bin", "1.8"); >+ project.open(null); >+ String fileContent = "package p;\n" + >+ "public interface Test {\n" + >+ " static void main(String[] args) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ "}"; >+ createFolder("/Bug428178/src/p"); >+ createFile( "/Bug428178/src/p/Test.java", fileContent); >+ >+ ICompilationUnit unit = getCompilationUnit("/Bug428178/src/p/Test.java"); >+ IMethod method = unit.getTypes()[0].getMethods()[0]; >+ assertNotNull("Method should not be null", method); >+ assertTrue("Should be a main method", method.isMainMethod()); >+ } >+ finally { >+ deleteProject("Bug428178"); >+ } >+ } >+ public void testBug428178a() throws Exception { >+ try { >+ IJavaProject project = createJavaProject("Bug428178", new String[] {"src"}, new String[] {"JCL18_FULL"}, "bin", "1.8"); >+ project.open(null); >+ String fileContent = "package p;\n" + >+ "public interface Test {\n" + >+ " static void main(String[] args) {\n" + >+ " System.out.println(\"Hello\");\n" + >+ " }\n" + >+ "}"; >+ addLibrary(project, >+ "lib.jar", >+ "src.zip", new >+ String[] {"p/Test.java", fileContent}, >+ JavaCore.VERSION_1_8); >+ IType type = getPackageFragmentRoot("Bug428178", "lib.jar").getPackageFragment("p").getClassFile("Test.class").getType(); >+ IMethod method = type.getMethods()[0]; >+ assertNotNull("Method should not be null", method); >+ assertTrue("Should be a main method", method.isMainMethod()); >+ } >+ finally { >+ deleteProject("Bug428178"); >+ } >+ } >+} >diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java >index 8cad15a..ab86ad7 100644 >--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java >+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java >@@ -1,8 +1,12 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2013 IBM Corporation and others. >+ * Copyright (c) 2000, 2014 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. > * > * Contributors: >@@ -357,5 +361,8 @@ > if ("main".equals(method.getElementName()) && Signature.SIG_VOID.equals(method.getReturnType())) { //$NON-NLS-1$ > int flags= method.getFlags(); >- if (Flags.isStatic(flags) && Flags.isPublic(flags)) { >+ IType declaringType = null; >+ if (Flags.isStatic(flags) && >+ (Flags.isPublic(flags) || >+ ((declaringType = getDeclaringType()) != null && declaringType.isInterface()))) { > String[] paramTypes= method.getParameterTypes(); > if (paramTypes.length == 1) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 428178
: 239952