diff --git a/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.java b/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.java new file mode 100644 index 00000000000..9539e48d265 --- /dev/null +++ b/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.java @@ -0,0 +1,7 @@ +package test; + +public final class ClassWithObjectMethod { + public String toString() { + return ""; + } +} \ No newline at end of file diff --git a/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.txt b/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.txt new file mode 100644 index 00000000000..d027f6561b0 --- /dev/null +++ b/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.txt @@ -0,0 +1,16 @@ +package test + +public final class ClassWithObjectMethod : java.lang.Object { + public constructor ClassWithObjectMethod() + protected open override /*1*/ /*fake_override*/ fun clone() : jet.Any? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ p0 : jet.Any?) : jet.Boolean + protected open override /*1*/ /*fake_override*/ fun finalize() : jet.Unit + public final override /*1*/ /*fake_override*/ fun getClass() : java.lang.Class? + public open override /*1*/ /*fake_override*/ fun hashCode() : jet.Int + public final override /*1*/ /*fake_override*/ fun notify() : jet.Unit + public final override /*1*/ /*fake_override*/ fun notifyAll() : jet.Unit + public open override /*1*/ fun toString() : jet.String? + public final override /*1*/ /*fake_override*/ fun wait() : jet.Unit + public final override /*1*/ /*fake_override*/ fun wait(/*0*/ p0 : jet.Long) : jet.Unit + public final override /*1*/ /*fake_override*/ fun wait(/*0*/ p0 : jet.Long, /*1*/ p1 : jet.Int) : jet.Unit +} diff --git a/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/InterfaceWithObjectMethods.java b/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/InterfaceWithObjectMethods.java new file mode 100644 index 00000000000..f9b8ef9ded3 --- /dev/null +++ b/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/InterfaceWithObjectMethods.java @@ -0,0 +1,9 @@ +package test; + +public interface InterfaceWithObjectMethods { + int hashCode(); + boolean equals(Object obj); + Object clone(); + String toString(); + void finalize(); +} \ No newline at end of file diff --git a/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/InterfaceWithObjectMethods.txt b/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/InterfaceWithObjectMethods.txt new file mode 100644 index 00000000000..d1655aa4875 --- /dev/null +++ b/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/InterfaceWithObjectMethods.txt @@ -0,0 +1,15 @@ +package test + +public trait InterfaceWithObjectMethods : java.lang.Object { + public abstract override /*1*/ fun clone() : jet.Any? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ p0 : jet.Any?) : jet.Boolean + public abstract override /*1*/ fun finalize() : jet.Unit + public final override /*1*/ /*fake_override*/ fun getClass() : java.lang.Class? + public open override /*1*/ /*fake_override*/ fun hashCode() : jet.Int + public final override /*1*/ /*fake_override*/ fun notify() : jet.Unit + public final override /*1*/ /*fake_override*/ fun notifyAll() : jet.Unit + public open override /*1*/ /*fake_override*/ fun toString() : jet.String? + public final override /*1*/ /*fake_override*/ fun wait() : jet.Unit + public final override /*1*/ /*fake_override*/ fun wait(/*0*/ p0 : jet.Long) : jet.Unit + public final override /*1*/ /*fake_override*/ fun wait(/*0*/ p0 : jet.Long, /*1*/ p1 : jet.Int) : jet.Unit +} diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractLoadJavaTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractLoadJavaTest.java index 5816eaf3ca4..3ab3fa6aa7b 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractLoadJavaTest.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractLoadJavaTest.java @@ -70,6 +70,14 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir { } protected void doTestCompiledJava(@NotNull String javaFileName) throws Exception { + doTestCompiledJava(javaFileName, DONT_INCLUDE_METHODS_OF_OBJECT); + } + + protected void doTestCompiledJavaIncludeObjectMethods(@NotNull String javaFileName) throws Exception { + doTestCompiledJava(javaFileName, RECURSIVE); + } + + private void doTestCompiledJava(@NotNull String javaFileName, Configuration configuration) throws Exception { final File srcDir = new File(tmpdir, "src"); File compiledDir = new File(tmpdir, "compiled"); assertTrue(srcDir.mkdir()); @@ -97,7 +105,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir { Pair javaNamespaceAndContext = compileJavaAndLoadTestNamespaceAndBindingContextFromBinary( srcFiles, compiledDir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY); - checkJavaNamespace(new File(javaFileName.replaceFirst("\\.java$", ".txt")), javaNamespaceAndContext.first, javaNamespaceAndContext.second); + checkJavaNamespace(new File(javaFileName.replaceFirst("\\.java$", ".txt")), javaNamespaceAndContext.first, javaNamespaceAndContext.second, configuration); } protected void doTestSourceJava(@NotNull String javaFileName) throws Exception { @@ -111,7 +119,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir { Pair javaNamespaceAndContext = loadTestNamespaceAndBindingContextFromJavaRoot( tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY); - checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second); + checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second, DONT_INCLUDE_METHODS_OF_OBJECT); } protected void doTestJavaAgainstKotlin(String expectedFileName) throws Exception { @@ -153,7 +161,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir { LoadDescriptorUtil.TEST_PACKAGE_FQNAME, DescriptorSearchRule.INCLUDE_KOTLIN); assert namespaceDescriptor != null : "Test namespace not found"; - checkJavaNamespace(expectedFile, namespaceDescriptor, trace.getBindingContext()); + checkJavaNamespace(expectedFile, namespaceDescriptor, trace.getBindingContext(), DONT_INCLUDE_METHODS_OF_OBJECT); } private static void checkForLoadErrorsAndCompare( @@ -200,12 +208,13 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir { private static void checkJavaNamespace( final File txtFile, final NamespaceDescriptor javaNamespace, - BindingContext bindingContext + BindingContext bindingContext, + final Configuration configuration ) { checkForLoadErrorsAndCompare(javaNamespace, bindingContext, new Runnable() { @Override public void run() { - compareNamespaceWithFile(javaNamespace, DONT_INCLUDE_METHODS_OF_OBJECT, txtFile); + compareNamespaceWithFile(javaNamespace, configuration, txtFile); } }); } diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java index 748d2219c06..4751df1feb5 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java @@ -30,7 +30,7 @@ import org.jetbrains.jet.jvm.compiler.AbstractLoadJavaTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") -@InnerTestClasses({LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJava.class, LoadJavaTestGenerated.SourceJava.class, LoadJavaTestGenerated.JavaAgainstKotlin.class}) +@InnerTestClasses({LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJavaIncludeObjectMethods.class, LoadJavaTestGenerated.CompiledJava.class, LoadJavaTestGenerated.SourceJava.class, LoadJavaTestGenerated.JavaAgainstKotlin.class}) public class LoadJavaTestGenerated extends AbstractLoadJavaTest { @TestMetadata("compiler/testData/loadJava/compiledJavaCompareWithKotlin") @InnerTestClasses({CompiledJavaCompareWithKotlin.Annotation.class, CompiledJavaCompareWithKotlin.Constructor.class, CompiledJavaCompareWithKotlin.JavaBean.class, CompiledJavaCompareWithKotlin.KotlinSignature.class, CompiledJavaCompareWithKotlin.Library.class, CompiledJavaCompareWithKotlin.Modality.class, CompiledJavaCompareWithKotlin.NotNull.class, CompiledJavaCompareWithKotlin.Vararg.class}) @@ -970,6 +970,24 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { } } + @TestMetadata("compiler/testData/loadJava/compiledJavaIncludeObjectMethods") + public static class CompiledJavaIncludeObjectMethods extends AbstractLoadJavaTest { + public void testAllFilesPresentInCompiledJavaIncludeObjectMethods() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJavaIncludeObjectMethods"), Pattern.compile("^(.+)\\.java$"), true); + } + + @TestMetadata("ClassWithObjectMethod.java") + public void testClassWithObjectMethod() throws Exception { + doTestCompiledJavaIncludeObjectMethods("compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.java"); + } + + @TestMetadata("InterfaceWithObjectMethods.java") + public void testInterfaceWithObjectMethods() throws Exception { + doTestCompiledJavaIncludeObjectMethods("compiler/testData/loadJava/compiledJavaIncludeObjectMethods/InterfaceWithObjectMethods.java"); + } + + } + @TestMetadata("compiler/testData/loadJava/compiledJava") @InnerTestClasses({CompiledJava.Annotations.class, CompiledJava.ProtectedPackage.class, CompiledJava.ProtectedStatic.class, CompiledJava.SignaturePropagation.class, CompiledJava.SingleAbstractMethod.class, CompiledJava.Static.class}) public static class CompiledJava extends AbstractLoadJavaTest { @@ -1323,6 +1341,7 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { public static Test suite() { TestSuite suite = new TestSuite("LoadJavaTestGenerated"); suite.addTest(CompiledJavaCompareWithKotlin.innerSuite()); + suite.addTestSuite(CompiledJavaIncludeObjectMethods.class); suite.addTest(CompiledJava.innerSuite()); suite.addTestSuite(SourceJava.class); suite.addTest(JavaAgainstKotlin.innerSuite()); diff --git a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java index c584a151485..df6bab4f763 100644 --- a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java +++ b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java @@ -149,6 +149,7 @@ public class GenerateTests { "LoadJavaTestGenerated", AbstractLoadJavaTest.class, testModel("compiler/testData/loadJava/compiledJavaCompareWithKotlin", true, "java", "doTest"), + testModel("compiler/testData/loadJava/compiledJavaIncludeObjectMethods", true, "java", "doTestCompiledJavaIncludeObjectMethods"), testModel("compiler/testData/loadJava/compiledJava", true, "java", "doTestCompiledJava"), testModel("compiler/testData/loadJava/sourceJava", true, "java", "doTestSourceJava"), testModel("compiler/testData/loadJava/javaAgainstKotlin", true, "txt", "doTestJavaAgainstKotlin")