diff --git a/compiler/testData/loadJavaDescriptors/packageLocalVisibility/expected.txt b/compiler/testData/loadJavaDescriptors/packageLocalVisibility/expected.txt new file mode 100644 index 00000000000..9c1006d08c8 --- /dev/null +++ b/compiler/testData/loadJavaDescriptors/packageLocalVisibility/expected.txt @@ -0,0 +1,6 @@ +namespace test + +public open class test.JFrame : awt.Frame { + public final /*constructor*/ fun (): test.JFrame + protected final var accessibleContext: jet.String? +} diff --git a/compiler/testData/loadJavaDescriptors/packageLocalVisibility/java/awt/Frame.java b/compiler/testData/loadJavaDescriptors/packageLocalVisibility/java/awt/Frame.java new file mode 100644 index 00000000000..d8054f8922d --- /dev/null +++ b/compiler/testData/loadJavaDescriptors/packageLocalVisibility/java/awt/Frame.java @@ -0,0 +1,23 @@ +/* + * 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 awt; + +public class Frame { + + String accessibleContext = null; + +} diff --git a/compiler/testData/loadJavaDescriptors/packageLocalVisibility/java/test/JFrame.java b/compiler/testData/loadJavaDescriptors/packageLocalVisibility/java/test/JFrame.java new file mode 100644 index 00000000000..2cb684d9dd9 --- /dev/null +++ b/compiler/testData/loadJavaDescriptors/packageLocalVisibility/java/test/JFrame.java @@ -0,0 +1,27 @@ +/* + * 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 test; + +import awt.Frame; + +public class JFrame extends Frame { + public JFrame() { + } + + protected String accessibleContext = null; +} + diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaDescriptorsTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaDescriptorsTest.java new file mode 100644 index 00000000000..f3243e3c6c3 --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaDescriptorsTest.java @@ -0,0 +1,66 @@ +/* + * 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 com.google.common.base.Function; +import com.google.common.collect.Collections2; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.ConfigurationKind; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; +import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; +import org.jetbrains.jet.lang.resolve.lazy.KotlinTestWithEnvironment; +import org.jetbrains.jet.test.util.NamespaceComparator; + +import java.io.File; +import java.util.Arrays; +import java.util.Collection; + +/** + * @author Pavel Talanov + */ +public final class LoadJavaDescriptorsTest extends KotlinTestWithEnvironment { + @NotNull + private final String PATH = "compiler/testData/loadJavaDescriptors"; + + @Override + protected JetCoreEnvironment createEnvironment() { + return createEnvironmentWithMockJdk(ConfigurationKind.JDK_AND_ANNOTATIONS); + } + + private void doTest(@NotNull String expectedFileName, @NotNull String... javaFileNames) throws Exception { + Collection files = Collections2.transform(Arrays.asList(javaFileNames), new Function() { + @Override + public File apply(String s) { + return new File(s); + } + }); + File expected = new File(expectedFileName); + File tmpDir = JetTestUtils.tmpDir(expected.getName()); + NamespaceDescriptor javaNamespaceDescriptor = LoadJavaDescriptorUtil.compileJava(files, tmpDir, getTestRootDisposable()); + //NOTE: comparing namespace to file (hack) + NamespaceComparator.compareNamespaces(javaNamespaceDescriptor, javaNamespaceDescriptor, false, expected); + } + + public void testPackageLocalVisibility() throws Exception { + String dir = PATH + "/packageLocalVisibility"; + String javaDir = dir + "/java"; + doTest(dir + "/expected.txt", + javaDir + "/test/JFrame.java", + javaDir + "/awt/Frame.java"); + } +}