Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-09-25 22:44:07 +0000
committerStephan Herrmann2012-09-25 22:44:07 +0000
commitdd3bff4d99a5193497eb7e3c0e1bc46a32b7c36a (patch)
tree28784238e6b0abd0a76578734e3862d3f79bee80
parent8a3b59860042c242d4e16ee3f50746d591d948f0 (diff)
downloadeclipse.jdt.core-dd3bff4d99a5193497eb7e3c0e1bc46a32b7c36a.tar.gz
eclipse.jdt.core-dd3bff4d99a5193497eb7e3c0e1bc46a32b7c36a.tar.xz
eclipse.jdt.core-dd3bff4d99a5193497eb7e3c0e1bc46a32b7c36a.zip
Bug 388954 - [1.8][compiler] detect default methods in class files
- incl. revert of one patch from bug 388800 - replace with new strategy to fix-up tests by adding stub impls.
-rw-r--r--org.eclipse.jdt.core.tests.compiler/.gitignore1
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java197
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java12
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java25
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java10
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java13
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java49
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java7
-rw-r--r--org.eclipse.jdt.core.tests.model/.gitignore1
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java12
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java9
11 files changed, 296 insertions, 40 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/.gitignore b/org.eclipse.jdt.core.tests.compiler/.gitignore
new file mode 100644
index 0000000000..650e4590ec
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/.gitignore
@@ -0,0 +1 @@
+/test.dat
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index 4f4f8e502c..5b50060559 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
@@ -11,7 +11,9 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Stephan Herrmann - Contribution for bug 335093 - [compiler][null] minimal hook for future null annotation support
+ * Stephan Herrmann - Contribution for
+ * bug 335093 - [compiler][null] minimal hook for future null annotation support
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -68,6 +70,199 @@ import org.eclipse.jdt.internal.core.search.JavaSearchParticipant;
import org.eclipse.jdt.internal.core.search.indexing.BinaryIndexer;
public abstract class AbstractRegressionTest extends AbstractCompilerTest implements StopableTestCase {
+
+ // for compiling against JRE 8:
+ static final boolean IS_JRE_8;
+ static final String COMPARATOR_IMPL_JRE8;
+ static final String COMPARATOR_RAW_IMPL_JRE8;
+ static final String COLLECTION_IMPL_JRE8;
+ static final String COLLECTION_RAW_IMPL_JRE8;
+ static final String LIST_IMPL_JRE8;
+ static final String LIST_RAW_IMPL_JRE8;
+ static final String ITERABLE_IMPL_JRE8;
+ static final String ITERABLE_RAW_IMPL_JRE8;
+ static final String ITERABLE_RAW_WITHOUT_IS_EMPTY_IMPL_JRE8;
+ static final String MAP_IMPL_JRE8;
+ static final String MAP_RAW_IMPL_JRE8;
+ static final String MAP_STREAM_IMPL_JRE8;
+ static final String MAP_STREAM_RAW_IMPL_JRE8;
+
+ static {
+ String javaVersion = System.getProperty("java.specification.version");
+ IS_JRE_8 = "1.8".equals(javaVersion);
+ if (IS_JRE_8) { // TODO(stephan) accommodate future versions ...
+ COMPARATOR_IMPL_JRE8 =
+ " public java.util.Comparator<*> compose(java.util.Comparator<? super *> other) { return null; }\n" +
+ " public java.util.Comparator<*> reverse() { return null; }\n";
+ COMPARATOR_RAW_IMPL_JRE8 =
+ " public java.util.Comparator compose(java.util.Comparator other) { return null; }\n" +
+ " public java.util.Comparator reverse() { return null; }\n";
+ COLLECTION_IMPL_JRE8 =
+ " public boolean retainAll(java.util.functions.Predicate<? super *> filter) { return false; }\n" +
+ " public boolean removeAll(java.util.functions.Predicate<? super *> filter) { return false; }\n" +
+ " public void addAll(Iterable<? extends *> source) { }\n";
+ COLLECTION_RAW_IMPL_JRE8 =
+ " public @SuppressWarnings(\"rawtypes\") boolean retainAll(java.util.functions.Predicate filter) { return false; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") boolean removeAll(java.util.functions.Predicate filter) { return false; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") void addAll(Iterable source) { }\n";
+ LIST_IMPL_JRE8 =// replace '*' with your concrete type argument
+ " public void sort(java.util.Comparator<? super *> comparator) {}\n" +
+ " public void parallelSort(java.util.Comparator<? super *> comparator) {}\n";
+ LIST_RAW_IMPL_JRE8 =
+ " public @SuppressWarnings(\"rawtypes\") void sort(java.util.Comparator comparator) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void parallelSort(java.util.Comparator comparator) {}\n";
+ ITERABLE_IMPL_JRE8 = // replace '*' with your concrete type argument
+ " public boolean isEmpty() { return false; }\n" +
+ " public long count() { return 0L; }\n" +
+ " public * getOnly() { return null; }\n" +
+ " public * getFirst() { return null; }\n" +
+ " public * getAny() { return null; }\n" +
+ " public * reduce(* base, java.util.functions.BinaryOperator<*> reducer) { return null; }\n" +
+ " public <A extends java.util.Fillable<? super *>> A into(A target) { return null; }\n" +
+ " public void forEach(java.util.functions.Block<? super *> block) {}\n" +
+ " public Iterable<*> sorted(java.util.Comparator<? super *> comparator) { return null; }\n" +
+ " public boolean anyMatch(java.util.functions.Predicate<? super *> filter) { return false; }\n" +
+ " public boolean allMatch(java.util.functions.Predicate<? super *> filter) { return false; }\n" +
+ " public boolean noneMatch(java.util.functions.Predicate<? super *> filter) { return false; }\n" +
+ " public Iterable<*> cumulate(java.util.functions.BinaryOperator<*> op) { return null; }\n" +
+ " public <U> MapStream<*,U> mapped(java.util.functions.Mapper<? super *, ? extends U> mapper) { return null; }\n" +
+ " public Iterable<*> filter(java.util.functions.Predicate<? super *> predicate) { return null; }\n" +
+ " public <U> Iterable<U> map(java.util.functions.Mapper<? super *, ? extends U> mapper) { return null; }\n" +
+ " public double mapReduce(java.util.functions.DoubleMapper<? super *> mapper, double base, java.util.functions.DoubleBinaryOperator reducer) { return 0; }\n" +
+ " public long mapReduce(java.util.functions.LongMapper<? super *> mapper, long base, java.util.functions.LongBinaryOperator reducer) { return 0; }\n" +
+ " public int mapReduce(java.util.functions.IntMapper<? super *> mapper, int base, java.util.functions.IntBinaryOperator reducer) { return 0; }\n" +
+ " public <U> U mapReduce(java.util.functions.Mapper<? super *, ? extends U> mapper, U base, java.util.functions.BinaryOperator<U> reducer) { return null; }\n" +
+ " public <U> Iterable<U> flatMap(java.util.functions.Mapper<? super *, ? extends Iterable<U>> mapper) { return null; }\n" +
+ " public <U> MapStream<U, Iterable<*>> groupBy(java.util.functions.Mapper<? super *, ? extends U> mapper) { return null; }\n" +
+ " public <U> MapStream<U, Iterable<*>> groupByMulti(java.util.functions.Mapper<? super *, ? extends Iterable<U>> mapper) { return null; }\n" +
+ " public Iterable<*> uniqueElements() { return null; }\n";
+ ITERABLE_RAW_IMPL_JRE8 =
+ " public boolean isEmpty() { return false; }\n" +
+ " public long count() { return 0L; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object getOnly() { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object getFirst() { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object getAny() { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object reduce(Object base, java.util.functions.BinaryOperator reducer) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") java.util.Fillable into(java.util.Fillable target) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") void forEach(java.util.functions.Block block) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable sorted(java.util.Comparator comparator) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") boolean anyMatch(java.util.functions.Predicate filter) { return false; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") boolean allMatch(java.util.functions.Predicate filter) { return false; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") boolean noneMatch(java.util.functions.Predicate filter) { return false; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable cumulate(java.util.functions.BinaryOperator op) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") MapStream mapped(java.util.functions.Mapper mapper) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable filter(java.util.functions.Predicate predicate) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable map(java.util.functions.Mapper mapper) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") double mapReduce(java.util.functions.DoubleMapper mapper, double base, java.util.functions.DoubleBinaryOperator reducer) { return 0; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") long mapReduce(java.util.functions.LongMapper mapper, long base, java.util.functions.LongBinaryOperator reducer) { return 0; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") int mapReduce(java.util.functions.IntMapper mapper, int base, java.util.functions.IntBinaryOperator reducer) { return 0; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object mapReduce(java.util.functions.Mapper mapper, Object base, java.util.functions.BinaryOperator reducer) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable flatMap(java.util.functions.Mapper mapper) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") MapStream groupBy(java.util.functions.Mapper mapper) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") MapStream groupByMulti(java.util.functions.Mapper mapper) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable uniqueElements() { return null; }\n";
+ ITERABLE_RAW_WITHOUT_IS_EMPTY_IMPL_JRE8 =
+ " public long count() { return 0L; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object getOnly() { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object getFirst() { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object getAny() { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object reduce(Object base, java.util.functions.BinaryOperator reducer) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") java.util.Fillable into(java.util.Fillable target) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") void forEach(java.util.functions.Block block) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable sorted(java.util.Comparator comparator) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") boolean anyMatch(java.util.functions.Predicate filter) { return false; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") boolean allMatch(java.util.functions.Predicate filter) { return false; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") boolean noneMatch(java.util.functions.Predicate filter) { return false; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable cumulate(java.util.functions.BinaryOperator op) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") MapStream mapped(java.util.functions.Mapper mapper) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable filter(java.util.functions.Predicate predicate) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable map(java.util.functions.Mapper mapper) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") double mapReduce(java.util.functions.DoubleMapper mapper, double base, java.util.functions.DoubleBinaryOperator reducer) { return 0; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") long mapReduce(java.util.functions.LongMapper mapper, long base, java.util.functions.LongBinaryOperator reducer) { return 0; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") int mapReduce(java.util.functions.IntMapper mapper, int base, java.util.functions.IntBinaryOperator reducer) { return 0; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object mapReduce(java.util.functions.Mapper mapper, Object base, java.util.functions.BinaryOperator reducer) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable flatMap(java.util.functions.Mapper mapper) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") MapStream groupBy(java.util.functions.Mapper mapper) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") MapStream groupByMulti(java.util.functions.Mapper mapper) { return null; }\n" +
+ " public @SuppressWarnings(\"rawtypes\") Iterable uniqueElements() { return null; }\n";
+ MAP_IMPL_JRE8 = // '!' stands for 'K,V', '*' for 'K'
+ " public Iterable<BiValue<!>> asIterable() { return null; }\n" +
+ " public Iterable<*> inputs() { return null; }\n";
+ MAP_RAW_IMPL_JRE8 =
+ " public Iterable asIterable() { return null; }\n" +
+ " public Iterable inputs() { return null; }\n";
+ MAP_STREAM_IMPL_JRE8 = // '*' stands for 'K', '%' for 'V'
+ " public BiValue<*,%> getOnly() { return null; }\n" +
+ " public <A extends Map<? super *, ? super %>> A into(A destination) { return null; }\n" +
+ " public void forEach(java.util.functions.BiBlock<? super *, ? super %> block) {}\n" +
+ " public MapStream<*, Iterable<%>> asMultiStream() { return null; }\n" +
+ " public <W> MapStream<*, Iterable<W>> mapValuesMulti(final java.util.functions.BiMapper<? super *, ? super %, Iterable<W>> mapper) { return null; }\n" +
+ " public MapStream<*,%> sorted(java.util.Comparator<? super *> comparator) { return null; }\n" +
+ " public boolean anyMatch(java.util.functions.BiPredicate<? super *, ? super %> predicate) { return false; }\n" +
+ " public boolean allMatch(java.util.functions.BiPredicate<? super *, ? super %> predicate) { return false; }\n" +
+ " public boolean noneMatch(java.util.functions.BiPredicate<? super *, ? super %> predicate) { return false; }\n" +
+ " public MapStream<*,%> merge(MapStream<*,%> other) { return null; }\n" +
+ " public MapStream<*,%> filter(final java.util.functions.BiPredicate<? super *, ? super %> predicate) { return null; }\n" +
+ " public MapStream<%,*> swap() { return null; }\n" +
+ " public BiValue<*,%> getAny() { return null; }\n" +
+ " public MapStream<*,%> filterKeys(final java.util.functions.Predicate<*> filter) { return null; }\n" +
+ " public MapStream<*,%> filterValues(final java.util.functions.Predicate<%> filter) { return null; }\n" +
+ " public <A extends Map<? super *, C>,C extends Collection<? super %>> A intoMulti(A destination, java.util.functions.Factory<C> factory) { return null; }\n" +
+ " public <W> MapStream<*,W> mapValues(final java.util.functions.Mapper<%,W> mapper) { return null; }\n" +
+ " public BiValue<*,%> getFirst() { return null; }\n" +
+ " public <W> MapStream<*, W> map(final java.util.functions.BiMapper<*, %, W> mapper) { return null; }\n";
+ MAP_STREAM_RAW_IMPL_JRE8 =
+ " public BiValue getOnly() { return null; }\n" +
+ " public Map into(Map destination) { return null; }\n" +
+ " public void forEach(java.util.functions.BiBlock block) {}\n" +
+ " public MapStream asMultiStream() { return null; }\n" +
+ " public MapStream mapValuesMulti(final java.util.functions.BiMapper mapper) { return null; }\n" +
+ " public MapStream sorted(java.util.Comparator comparator) { return null; }\n" +
+ " public boolean anyMatch(java.util.functions.BiPredicate predicate) { return false; }\n" +
+ " public boolean allMatch(java.util.functions.BiPredicate predicate) { return false; }\n" +
+ " public boolean noneMatch(java.util.functions.BiPredicate predicate) { return false; }\n" +
+ " public MapStream merge(MapStream other) { return null; }\n" +
+ " public MapStream filter(final java.util.functions.BiPredicate predicate) { return null; }\n" +
+ " public MapStream swap() { return null; }\n" +
+ " public BiValue getAny() { return null; }\n" +
+ " public MapStream filterKeys(final java.util.functions.Predicate filter) { return null; }\n" +
+ " public MapStream filterValues(final java.util.functions.Predicate filter) { return null; }\n" +
+ " public Map intoMulti(Map destination, java.util.functions.Factory factory) { return null; }\n" +
+ " public MapStream mapValues(final java.util.functions.Mapper mapper) { return null; }\n" +
+ " public BiValue getFirst() { return null; }\n" +
+ " public MapStream map(final java.util.functions.BiMapper mapper) { return null; }\n";
+ } else {
+ COMPARATOR_IMPL_JRE8 = "";
+ COMPARATOR_RAW_IMPL_JRE8 = "";
+ COLLECTION_IMPL_JRE8 = "";
+ COLLECTION_RAW_IMPL_JRE8 = "";
+ LIST_IMPL_JRE8 = "";
+ LIST_RAW_IMPL_JRE8 = "";
+ ITERABLE_IMPL_JRE8 = "";
+ ITERABLE_RAW_IMPL_JRE8 = "";
+ ITERABLE_RAW_WITHOUT_IS_EMPTY_IMPL_JRE8 = "";
+ MAP_IMPL_JRE8 = "";
+ MAP_RAW_IMPL_JRE8 = "";
+ MAP_STREAM_IMPL_JRE8 = "";
+ MAP_STREAM_RAW_IMPL_JRE8 = "";
+ }
+ }
+ String getListRawImplJRE8() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return LIST_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", "");
+ return LIST_RAW_IMPL_JRE8;
+ }
+ String getIterableRawImplJRE8() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return ITERABLE_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", "");
+ return ITERABLE_RAW_IMPL_JRE8;
+ }
+ String getCollectionRawImplJRE8() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return COLLECTION_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", "");
+ return COLLECTION_RAW_IMPL_JRE8;
+ }
+
// javac comparison related types, fields and methods - see runJavac for
// details
static class JavacCompiler {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
index 13f6920dae..575a1134fe 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
@@ -1,12 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
+ * Stephan Herrmann - Contribution for
+ * Bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -1101,6 +1107,7 @@ public void test023() {
" public Iterator<String> iterator() {\n" +
" return null;\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"----------\n" +
@@ -1628,6 +1635,7 @@ public void test034() throws Exception {
" public Iterator<String> iterator() {\n" +
" return new ArrayIterator<String>(new String[]{\"a\",\"b\"});\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"ab");
@@ -1723,6 +1731,7 @@ public void test035() throws Exception {
" public Iterator<String> iterator() {\n" +
" return new ArrayIterator<String>(new String[]{\"a\",\"b\"});\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"ab");
@@ -1798,6 +1807,7 @@ public void test036() throws Exception {
" X x = new X();\n" +
" x.foo(x);\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}",
},
"ab");
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 0809428192..9111beadb3 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
@@ -12,7 +12,9 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Stephan Herrmann - Contribution for bug 383690 - [compiler] location of error re uninitialized final field should be aligned
+ * Stephan Herrmann - Contribution for
+ * bug 383690 - [compiler] location of error re uninitialized final field should be aligned
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -4431,6 +4433,9 @@ public class GenericTypeTest extends AbstractComparableTest {
" }\n" +
" public int size() { return 0; }\n" +
" public Object get(int index) { return null; }\n" +
+ ITERABLE_RAW_IMPL_JRE8 +
+ COLLECTION_RAW_IMPL_JRE8 +
+ LIST_RAW_IMPL_JRE8 +
"}\n"
},
"SUCCESS");
@@ -6140,6 +6145,7 @@ public class GenericTypeTest extends AbstractComparableTest {
" public int compare(X x1, X x2) {\n" +
" return comparator.compare(function.eval(x1),function.eval(x2));\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
"}\n",
},
"");
@@ -8840,6 +8846,8 @@ public class GenericTypeTest extends AbstractComparableTest {
" public Set<Map.Entry<String, V>> entrySet() {\n" +
" return this.backingMap.entrySet();\n" +
" }\n" +
+ MAP_STREAM_IMPL_JRE8.replaceAll("\\*", "String").replace('%', 'V') +
+ MAP_IMPL_JRE8.replaceAll("!", "String,V").replaceAll("\\*", "String")+
"}\n",
},
"----------\n" +
@@ -10802,6 +10810,8 @@ public class GenericTypeTest extends AbstractComparableTest {
" };\n" +
" }\n" +
" public int size() {return 0;}\n" +
+ COLLECTION_RAW_IMPL_JRE8 +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "Entry<String,Integer>") +
"}"
}
);
@@ -11373,6 +11383,8 @@ public class GenericTypeTest extends AbstractComparableTest {
" }\n" +
" public Iterator<Runnable> iterator() {return null;}\n" +
" public int size() {return 0;}\n" +
+ COLLECTION_RAW_IMPL_JRE8 +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "Runnable") +
"}"
}
);
@@ -24899,6 +24911,9 @@ public void test0779() throws Exception {
" List<String> list = new AbstractList<String>() {\n" +
" @Override public int size() { return 0; }\n" +
" @Override public String get(int i) { return args.get(i); }\n" +
+ COLLECTION_IMPL_JRE8.replaceAll("\\*", "String") +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
+ LIST_IMPL_JRE8.replaceAll("\\*", "String") +
" };\n" +
" }\n" +
" }\n" +
@@ -24910,13 +24925,14 @@ public void test0779() throws Exception {
},
"SUCCESS");
+ String constantPoolIdx = IS_JRE_8 ? "149" : "36"; // depends on whether or not stubs for JRE8 default methods are included
String expectedOutput =
" // Method descriptor #31 (I)Ljava/lang/Object;\n" +
" // Stack: 2, Locals: 2\n" +
" public bridge synthetic java.lang.Object get(int arg0);\n" +
" 0 aload_0 [this]\n" +
" 1 iload_1 [arg0]\n" +
- " 2 invokevirtual X$Entry$1.get(int) : java.lang.String [36]\n" +
+ " 2 invokevirtual X$Entry$1.get(int) : java.lang.String ["+constantPoolIdx+"]\n" +
" 5 areturn\n" +
" Line numbers:\n" +
" [pc: 0, line: 1]\n";
@@ -28018,6 +28034,8 @@ public void test0868() {
" // TODO Auto-generated method stub\n" +
" \n" +
" }" +
+ COLLECTION_RAW_IMPL_JRE8 +
+ ITERABLE_RAW_WITHOUT_IS_EMPTY_IMPL_JRE8 +
"}",
},
"",
@@ -34170,6 +34188,7 @@ public void test1030() {
" public Iterator<W> iterator() {\n" +
" return theList.iterator();\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replace('*', 'W') +
" }\n" +
"\n" +
" private PointList<Waypoint> waypoints = new PointList<Waypoint>();\n" +
@@ -34414,6 +34433,7 @@ public void test1035() {
"public int compare(T obj1, T obj2) {\n" +
" return obj1.compareTo(obj2);\n" +
"}\n" +
+ COMPARATOR_IMPL_JRE8.replace('*', 'T') +
"}\n" +
"\n" +
"@SuppressWarnings({\"unchecked\", \"rawtypes\"})\n" +
@@ -34464,6 +34484,7 @@ public void test1035() {
"public int compare(V obj1, V obj2) {\n" +
" return 0;\n" +
"}\n" +
+ COMPARATOR_IMPL_JRE8.replace('*', 'V') +
"}", // =================
},
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java
index 7e127d424f..85d3cddf44 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java
@@ -1,12 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * Copyright (c) 2006, 2012 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
+ * Stephan Herrmann - Contribution for
+ * Bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -6854,6 +6860,7 @@ public void test173() throws Exception {
" compare(yourList != null ? yourList : myList, yourList);\n" +
" return 0;\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
" };\n" +
" System.out.println(\"SUCCESS\");\n" +
" }\n" +
@@ -6884,6 +6891,7 @@ public void test174() throws Exception {
" private int foo(int i, int j) {\n" +
" return i - j;\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
" };\n" +
" System.out.println(\"SUCCESS\");\n" +
" }\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java
index a53b3e5d04..53623c9803 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java
@@ -1,13 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
- * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for
+ * bug 185682 - Increment/decrement operators mark local variables as read
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -2561,6 +2567,9 @@ public void test075() {
" public int size() {\n" +
" return 0;\n" +
" }\n" +
+ getListRawImplJRE8() +
+ getIterableRawImplJRE8() +
+ getCollectionRawImplJRE8() +
"}", // =================
},
"");
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
index 62aa4c2ee4..7ae24f6a0b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
@@ -12,7 +12,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contribution for
- * Bug 388800 - [1.8] adjust tests to 1.8 JRE
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -62,12 +62,6 @@ public class MethodVerifyTest extends AbstractComparableTest {
? " must override a superclass method\n"
: " must override or implement a supertype method\n");
}
-
- boolean isJava8JRE() {
- String version = System.getProperty("java.specification.version");
- return "1.8".equals(version);
- }
-
public void test001() {
this.runNegativeTest(
new String[] {
@@ -1823,8 +1817,11 @@ public class MethodVerifyTest extends AbstractComparableTest {
this.runConformTest(
new String[] {
"X.java",
+ "import java.util.*;\n" +
"public class X extends java.util.AbstractMap {\n" +
" public java.util.Set entrySet() { return null; }\n" +
+ MAP_RAW_IMPL_JRE8 +
+ MAP_STREAM_RAW_IMPL_JRE8 +
"}\n"
},
""
@@ -6848,13 +6845,6 @@ X.java:7: name clash: <T#1>foo2(T#1) in X and <T#2>foo2(A) in Y have the same er
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=148783
public void test091() {
- String j8warning = isJava8JRE()
- ? "16. WARNING in DataSet.java (at line 34)\n" +
- " public void remove() {}\n" +
- " ^^^^^^^^\n" +
- "The method remove() of type DataSet<T> should be tagged with @Override since it actually overrides a superclass method\n" +
- "----------\n"
- : "";
this.runNegativeTest(
new String[] {
"DataSet.java",//===================
@@ -6892,6 +6882,9 @@ X.java:7: name clash: <T#1>foo2(T#1) in X and <T#2>foo2(A) in Y have the same er
" public boolean hasNext() { return false; }\n" +
" public Object next() { return null; }\n" +
" public void remove() {}\n" +
+ ITERABLE_RAW_WITHOUT_IS_EMPTY_IMPL_JRE8 +
+ COLLECTION_RAW_IMPL_JRE8 +
+ LIST_RAW_IMPL_JRE8 +
"}\n", // =================
},
"----------\n" +
@@ -6970,19 +6963,11 @@ X.java:7: name clash: <T#1>foo2(T#1) in X and <T#2>foo2(A) in Y have the same er
" ^^^^\n" +
"List is a raw type. References to generic type List<E> should be parameterized\n" +
"----------\n"
- + j8warning
);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=148783 - variation
public void test092() {
- String j8warning = isJava8JRE()
- ? "14. WARNING in DataSet.java (at line 34)\n" +
- " public void remove() {}\n" +
- " ^^^^^^^^\n" +
- "The method remove() of type DataSet<T> should be tagged with @Override since it actually overrides a superclass method\n" +
- "----------\n"
- : "";
this.runNegativeTest(
new String[] {
"DataSet.java",//===================
@@ -7020,6 +7005,9 @@ X.java:7: name clash: <T#1>foo2(T#1) in X and <T#2>foo2(A) in Y have the same er
" public boolean hasNext() { return false; }\n" +
" public Object next() { return null; }\n" +
" public void remove() {}\n" +
+ ITERABLE_RAW_WITHOUT_IS_EMPTY_IMPL_JRE8 +
+ COLLECTION_RAW_IMPL_JRE8 +
+ LIST_RAW_IMPL_JRE8 +
"}\n", // =================
},
"----------\n" +
@@ -7087,18 +7075,10 @@ X.java:7: name clash: <T#1>foo2(T#1) in X and <T#2>foo2(A) in Y have the same er
" public List subList(int fromIndex, int toIndex) { return null; }\n" +
" ^^^^\n" +
"List is a raw type. References to generic type List<E> should be parameterized\n" +
- "----------\n"
- +j8warning);
+ "----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=148783 - variation
public void test093() {
- String j8warning = isJava8JRE()
- ? "18. WARNING in DataSet.java (at line 36)\n" +
- " public void remove() {}\n" +
- " ^^^^^^^^\n" +
- "The method remove() of type DataSet<T> should be tagged with @Override since it actually overrides a superclass method\n" +
- "----------\n"
- : "";
this.runNegativeTest(
new String[] {
"DataSet.java",//===================
@@ -7138,6 +7118,9 @@ X.java:7: name clash: <T#1>foo2(T#1) in X and <T#2>foo2(A) in Y have the same er
" public boolean hasNext() { return false; }\n" +
" public Object next() { return null; }\n" +
" public void remove() {}\n" +
+ ITERABLE_RAW_WITHOUT_IS_EMPTY_IMPL_JRE8 +
+ COLLECTION_RAW_IMPL_JRE8 +
+ LIST_RAW_IMPL_JRE8 +
"}\n", // =================
},
"----------\n" +
@@ -7226,7 +7209,6 @@ X.java:7: name clash: <T#1>foo2(T#1) in X and <T#2>foo2(A) in Y have the same er
" ^^^^\n" +
"List is a raw type. References to generic type List<E> should be parameterized\n" +
"----------\n"
- +j8warning
);
}
@@ -11424,6 +11406,7 @@ public void test203() {
" return compare((I) o1, (I) o2);\n" +
" }\n" +
" public int compare(I o1, I o2) { return 0; }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
"}"
},
""
@@ -12336,6 +12319,7 @@ public void test331446() {
" public int compare(Object o1, Object o2) {\n" +
" return 0;\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
" };\n" +
" Test.assertEquals(\"Test\", comparator, new ArrayList(), new ArrayList());\n" +
" }\n" +
@@ -12406,6 +12390,7 @@ public void test331446a() {
" public int compare(Object o1, Object o2) {\n" +
" return 0;\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
" };\n" +
" Test.assertEquals(\"Test\", comparator, new ArrayList(), new ArrayList());\n" +
" }\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
index 35d56a510b..e50b97dbbf 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
@@ -4,9 +4,15 @@
* 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
+ * Stephan Herrmann - Contribution for
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -1777,6 +1783,7 @@ public class StackMapAttributeTest extends AbstractRegressionTest {
" public Iterator<Value_Type> iterator() {\n" +
" return null;\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "Value_Type") +
"}\n" +
"\n" +
"class BirBlock {\n" +
diff --git a/org.eclipse.jdt.core.tests.model/.gitignore b/org.eclipse.jdt.core.tests.model/.gitignore
new file mode 100644
index 0000000000..650e4590ec
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/.gitignore
@@ -0,0 +1 @@
+/test.dat
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
index 4d6f01c3f4..55676551db 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
@@ -4,6 +4,10 @@
* 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
@@ -14,6 +18,7 @@
* bug 365387 - [compiler][null] bug 186342: Issues to follow up post review and verification.
* bug 358903 - Filter practically unimportant resource leak warnings
* bug 365531 - [compiler][null] investigate alternative strategy for internally encoding nullness defaults
+ * bug 388800 - [1.8][compiler] detect default methods in class files
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -451,6 +456,13 @@ private MethodBinding createMethod(IBinaryMethod method, long sourceLevel, char[
int methodModifiers = method.getModifiers() | ExtraCompilerModifiers.AccUnresolved;
if (sourceLevel < ClassFileConstants.JDK1_5)
methodModifiers &= ~ClassFileConstants.AccVarargs; // vararg methods are not recognized until 1.5
+ if (isInterface() && (methodModifiers & ClassFileConstants.AccAbstract) == 0) {
+ // see https://bugs.eclipse.org/388954
+ if (sourceLevel >= ClassFileConstants.JDK1_8)
+ methodModifiers |= ExtraCompilerModifiers.AccDefaultMethod;
+ else
+ methodModifiers |= ClassFileConstants.AccAbstract;
+ }
ReferenceBinding[] exceptions = Binding.NO_EXCEPTIONS;
TypeBinding[] parameters = Binding.NO_PARAMETERS;
TypeVariableBinding[] typeVars = Binding.NO_TYPE_VARIABLES;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java
index 7e427f256c..f02abdb7bc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java
@@ -14,6 +14,7 @@
* Benjamin Muskalla - Contribution for bug 239066
* Stephan Herrmann - Contribution for
* bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
+ * bug 388954 - [1.8][compiler] detect default methods in class files
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -163,7 +164,13 @@ void checkAgainstInheritedMethods(MethodBinding currentMethod, MethodBinding[] m
// JLS 9.4.3 (Java8): default method cannot override method from j.l.Object
problemReporter(currentMethod).defaultMethodOverridesObjectMethod(currentMethod);
} else {
- currentMethod.modifiers |= ExtraCompilerModifiers.AccOverriding;
+ // TODO (stephan) using AccImplementing for overrides of a default method works well
+ // for OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation
+ // but we should check if it has bad side effects elsewhere.
+ if (inheritedMethod.isDefaultMethod())
+ currentMethod.modifiers |= ExtraCompilerModifiers.AccImplementing;
+ else
+ currentMethod.modifiers |= ExtraCompilerModifiers.AccOverriding;
}
}

Back to the top