diff --git a/compiler/testData/javaDescriptorResolver/staticMembers/Simple.java b/compiler/testData/javaDescriptorResolver/staticMembers/Simple.java new file mode 100644 index 00000000000..444aa4c3738 --- /dev/null +++ b/compiler/testData/javaDescriptorResolver/staticMembers/Simple.java @@ -0,0 +1,7 @@ +package test; + +public class Simple { + public static void bar() {} + + public void foo() {} +} \ No newline at end of file diff --git a/compiler/testData/javaDescriptorResolver/staticMembers/Simple_non_static.txt b/compiler/testData/javaDescriptorResolver/staticMembers/Simple_non_static.txt new file mode 100644 index 00000000000..d3aefed9fc2 --- /dev/null +++ b/compiler/testData/javaDescriptorResolver/staticMembers/Simple_non_static.txt @@ -0,0 +1,6 @@ +namespace test + +public open class test.Simple : java.lang.Object { + public final /*constructor*/ fun (): test.Simple + public open fun foo(): jet.Tuple0 +} diff --git a/compiler/testData/javaDescriptorResolver/staticMembers/Simple_static.txt b/compiler/testData/javaDescriptorResolver/staticMembers/Simple_static.txt new file mode 100644 index 00000000000..e31cb6e95d5 --- /dev/null +++ b/compiler/testData/javaDescriptorResolver/staticMembers/Simple_static.txt @@ -0,0 +1,3 @@ +namespace Simple + +public open fun bar(): jet.Tuple0 diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractJavaResolverDescriptorTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractJavaResolverDescriptorTest.java index 9068668c23e..708a4ce396f 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractJavaResolverDescriptorTest.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractJavaResolverDescriptorTest.java @@ -37,6 +37,11 @@ public abstract class AbstractJavaResolverDescriptorTest extends TestCaseWithTmp protected JavaDescriptorResolver javaDescriptorResolver; + protected void compileJavaFile(@NotNull String fileRelativePath) + throws IOException { + compileJavaFile(fileRelativePath, null); + } + protected void compileJavaFile(@NotNull String fileRelativePath, @Nullable String classPath) throws IOException { File javaFile = new File(getPath() + fileRelativePath); diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/StaticMembersJavaDescriptorResolverTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/StaticMembersJavaDescriptorResolverTest.java new file mode 100644 index 00000000000..e46aba91bb4 --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/StaticMembersJavaDescriptorResolverTest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.jvm.compiler; + +import junit.framework.Assert; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.resolve.name.FqName; + +import java.io.File; +import java.io.IOException; + +import static org.jetbrains.jet.test.util.NamespaceComparator.DONT_INCLUDE_METHODS_OF_OBJECT; +import static org.jetbrains.jet.test.util.NamespaceComparator.compareNamespaces; + +public final class StaticMembersJavaDescriptorResolverTest extends AbstractJavaResolverDescriptorTest { + + private static final String PATH = "compiler/testData/javaDescriptorResolver/staticMembers/"; + private static final String DEFAULT_PACKAGE = "test"; + + @NotNull + @Override + protected String getPath() { + return PATH; + } + + public void testSimple() throws Exception { + doTest(); + } + + private void doTest() throws IOException { + String name = getTestName(false); + compileJavaFile(name + ".java"); + NamespaceDescriptor namespaceWithClass = javaDescriptorResolver.resolveNamespace(new FqName(DEFAULT_PACKAGE)); + Assert.assertNotNull(namespaceWithClass); + compareNamespaces(namespaceWithClass, namespaceWithClass, DONT_INCLUDE_METHODS_OF_OBJECT, new File(PATH + name + "_non_static.txt")); + + NamespaceDescriptor namespaceWithStaticMembers = javaDescriptorResolver.resolveNamespace(new FqName(DEFAULT_PACKAGE + "." + name)); + Assert.assertNotNull(namespaceWithStaticMembers); + compareNamespaces(namespaceWithStaticMembers, namespaceWithStaticMembers, DONT_INCLUDE_METHODS_OF_OBJECT, + new File(PATH + name + "_static.txt")); + } +}