Move jet.JetObject -> kotlin.jvm.internal.KObject

Don't use JetObject as a marker class in KotlinRuntimeLibraryUtil anymore,
since there are other classes for this purpose (KotlinPackage, Unit)
This commit is contained in:
Alexander Udalov
2014-02-14 16:16:24 +04:00
parent d8066c8d56
commit 0da92e22a2
21 changed files with 46 additions and 50 deletions
@@ -52,7 +52,6 @@ import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants; import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames; import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames;
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker; import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
@@ -350,8 +349,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
sw.writeSuperclassEnd(); sw.writeSuperclassEnd();
List<JetType> interfaceSupertypes = Lists.newArrayList(); List<JetType> interfaceSupertypes = Lists.newArrayList();
FqNameUnsafe jetObjectFqName = JvmAbi.JET_OBJECT.getFqNameForClassNameWithoutDollars().toUnsafe(); boolean explicitKObject = false;
boolean explicitJetObject = false;
for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) { for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference()); JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
@@ -361,19 +359,20 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
interfaceSupertypes.add(superType); interfaceSupertypes.add(superType);
assert superClassDescriptor != null : "should be already checked by isInterface()"; assert superClassDescriptor != null : "should be already checked by isInterface()";
if (jetObjectFqName.equals(DescriptorUtils.getFqName(superClassDescriptor))) { if (JvmAbi.K_OBJECT.equalsTo(DescriptorUtils.getFqName(superClassDescriptor))) {
explicitJetObject = true; explicitKObject = true;
} }
} }
} }
LinkedHashSet<String> superInterfaces = new LinkedHashSet<String>(); LinkedHashSet<String> superInterfaces = new LinkedHashSet<String>();
if (!explicitJetObject) { if (!explicitKObject) {
Type kObject = asmTypeByFqNameWithoutInnerClasses(JvmAbi.K_OBJECT);
sw.writeInterface(); sw.writeInterface();
sw.writeClassBegin(Type.getObjectType(JvmAbi.JET_OBJECT.getInternalName())); sw.writeClassBegin(kObject);
sw.writeClassEnd(); sw.writeClassEnd();
sw.writeInterfaceEnd(); sw.writeInterfaceEnd();
superInterfaces.add(JvmAbi.JET_OBJECT.getInternalName()); superInterfaces.add(kObject.getInternalName());
} }
for (JetType supertype : interfaceSupertypes) { for (JetType supertype : interfaceSupertypes) {
@@ -1,4 +1,4 @@
public final class Class implements jet.JetObject { public final class Class implements kotlin.jvm.internal.KObject {
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
private final java.lang.String nullableVal = ""; private final java.lang.String nullableVal = "";
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
@@ -71,4 +71,4 @@ public final class Class implements jet.JetObject {
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public Class() { /* compiled code */ } public Class() { /* compiled code */ }
} }
@@ -1,4 +1,4 @@
public final class ClassObjectField implements jet.JetObject { public final class ClassObjectField implements kotlin.jvm.internal.KObject {
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
public static final java.lang.String x = ""; public static final java.lang.String x = "";
private static final java.lang.String y = ""; private static final java.lang.String y = "";
@@ -7,7 +7,7 @@ public final class ClassObjectField implements jet.JetObject {
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public ClassObjectField() { /* compiled code */ } public ClassObjectField() { /* compiled code */ }
public static final class object implements jet.JetObject { public static final class object implements kotlin.jvm.internal.KObject {
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
public final java.lang.String getX() { /* compiled code */ } public final java.lang.String getX() { /* compiled code */ }
@@ -15,4 +15,4 @@ public final class ClassObjectField implements jet.JetObject {
private object() { /* compiled code */ } private object() { /* compiled code */ }
} }
} }
@@ -1,4 +1,4 @@
public final class ClassWithConstructor implements jet.JetObject { public final class ClassWithConstructor implements kotlin.jvm.internal.KObject {
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public ClassWithConstructor(@org.jetbrains.annotations.Nullable @jet.runtime.typeinfo.JetValueParameter(name = "nullable", type = "?") java.lang.String nullable, @org.jetbrains.annotations.NotNull @jet.runtime.typeinfo.JetValueParameter(name = "notNull") java.lang.String notNull) { /* compiled code */ } public ClassWithConstructor(@org.jetbrains.annotations.Nullable @jet.runtime.typeinfo.JetValueParameter(name = "nullable", type = "?") java.lang.String nullable, @org.jetbrains.annotations.NotNull @jet.runtime.typeinfo.JetValueParameter(name = "notNull") java.lang.String notNull) { /* compiled code */ }
} }
@@ -1,4 +1,4 @@
public final class ClassWithConstructorAndProperties implements jet.JetObject { public final class ClassWithConstructorAndProperties implements kotlin.jvm.internal.KObject {
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
private final java.lang.String nullable; private final java.lang.String nullable;
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
@@ -12,4 +12,4 @@ public final class ClassWithConstructorAndProperties implements jet.JetObject {
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public ClassWithConstructorAndProperties(@org.jetbrains.annotations.Nullable @jet.runtime.typeinfo.JetValueParameter(name = "nullable", type = "?") java.lang.String nullable, @org.jetbrains.annotations.NotNull @jet.runtime.typeinfo.JetValueParameter(name = "notNull") java.lang.String notNull) { /* compiled code */ } public ClassWithConstructorAndProperties(@org.jetbrains.annotations.Nullable @jet.runtime.typeinfo.JetValueParameter(name = "nullable", type = "?") java.lang.String nullable, @org.jetbrains.annotations.NotNull @jet.runtime.typeinfo.JetValueParameter(name = "notNull") java.lang.String notNull) { /* compiled code */ }
} }
@@ -1,4 +1,4 @@
public interface Generic <N, NN> extends jet.JetObject { public interface Generic <N, NN> extends kotlin.jvm.internal.KObject {
N a(@jet.runtime.typeinfo.JetValueParameter(name = "n") N n); N a(@jet.runtime.typeinfo.JetValueParameter(name = "n") N n);
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
@@ -9,4 +9,4 @@ public interface Generic <N, NN> extends jet.JetObject {
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
NN b1(@org.jetbrains.annotations.Nullable @jet.runtime.typeinfo.JetValueParameter(name = "nn", type = "?") NN nn); NN b1(@org.jetbrains.annotations.Nullable @jet.runtime.typeinfo.JetValueParameter(name = "nn", type = "?") NN nn);
} }
@@ -1,4 +1,4 @@
public interface Primitives extends jet.JetObject { public interface Primitives extends kotlin.jvm.internal.KObject {
int $$int /* Real name is 'int' */(@jet.runtime.typeinfo.JetValueParameter(name = "x") int x); int $$int /* Real name is 'int' */(@jet.runtime.typeinfo.JetValueParameter(name = "x") int x);
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
@@ -40,4 +40,4 @@ public interface Primitives extends jet.JetObject {
float getFloat(); float getFloat();
double getDouble(); double getDouble();
} }
@@ -1,4 +1,4 @@
public final class PrivateInClass implements jet.JetObject { public final class PrivateInClass implements kotlin.jvm.internal.KObject {
private final java.lang.String nn = ""; private final java.lang.String nn = "";
private final java.lang.String n = ""; private final java.lang.String n = "";
@@ -9,4 +9,4 @@ public final class PrivateInClass implements jet.JetObject {
private final java.lang.String bar(@jet.runtime.typeinfo.JetValueParameter(name = "a") java.lang.String a, @jet.runtime.typeinfo.JetValueParameter(name = "b", type = "?") java.lang.String b) { /* compiled code */ } private final java.lang.String bar(@jet.runtime.typeinfo.JetValueParameter(name = "a") java.lang.String a, @jet.runtime.typeinfo.JetValueParameter(name = "b", type = "?") java.lang.String b) { /* compiled code */ }
private PrivateInClass(@jet.runtime.typeinfo.JetValueParameter(name = "s", type = "?") java.lang.String s) { /* compiled code */ } private PrivateInClass(@jet.runtime.typeinfo.JetValueParameter(name = "s", type = "?") java.lang.String s) { /* compiled code */ }
} }
@@ -1,4 +1,4 @@
public interface PrivateInTrait extends jet.JetObject { public interface PrivateInTrait extends kotlin.jvm.internal.KObject {
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
java.lang.String getNn(); java.lang.String getNn();
@@ -7,4 +7,4 @@ public interface PrivateInTrait extends jet.JetObject {
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
java.lang.String bar(@org.jetbrains.annotations.NotNull @jet.runtime.typeinfo.JetValueParameter(name = "a") java.lang.String a, @org.jetbrains.annotations.Nullable @jet.runtime.typeinfo.JetValueParameter(name = "b", type = "?") java.lang.String b); java.lang.String bar(@org.jetbrains.annotations.NotNull @jet.runtime.typeinfo.JetValueParameter(name = "a") java.lang.String a, @org.jetbrains.annotations.Nullable @jet.runtime.typeinfo.JetValueParameter(name = "b", type = "?") java.lang.String b);
} }
@@ -1,14 +1,14 @@
public final class Synthetic implements jet.JetObject { public final class Synthetic implements kotlin.jvm.internal.KObject {
private final void foo() { /* compiled code */ } private final void foo() { /* compiled code */ }
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public Synthetic() { /* compiled code */ } public Synthetic() { /* compiled code */ }
public final class Inner implements jet.JetObject { public final class Inner implements kotlin.jvm.internal.KObject {
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public final void test() { /* compiled code */ } public final void test() { /* compiled code */ }
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public Inner() { /* compiled code */ } public Inner() { /* compiled code */ }
} }
} }
@@ -1,4 +1,4 @@
public interface Trait extends jet.JetObject { public interface Trait extends kotlin.jvm.internal.KObject {
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
java.lang.String notNull(@org.jetbrains.annotations.NotNull @jet.runtime.typeinfo.JetValueParameter(name = "a") java.lang.String a); java.lang.String notNull(@org.jetbrains.annotations.NotNull @jet.runtime.typeinfo.JetValueParameter(name = "a") java.lang.String a);
@@ -36,4 +36,4 @@ public interface Trait extends jet.JetObject {
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
void setNotNullVar(@org.jetbrains.annotations.NotNull @jet.runtime.typeinfo.JetValueParameter(name = "<set-?>") java.lang.String p); void setNotNullVar(@org.jetbrains.annotations.NotNull @jet.runtime.typeinfo.JetValueParameter(name = "<set-?>") java.lang.String p);
} }
@@ -1,9 +1,9 @@
public interface TraitClassObjectField extends jet.JetObject { public interface TraitClassObjectField extends kotlin.jvm.internal.KObject {
TraitClassObjectField.object object$; TraitClassObjectField.object object$;
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
java.lang.String x = ""; java.lang.String x = "";
static final class object implements jet.JetObject { static final class object implements kotlin.jvm.internal.KObject {
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
private final java.lang.String x = ""; private final java.lang.String x = "";
private final java.lang.String y = ""; private final java.lang.String y = "";
@@ -15,4 +15,4 @@ public interface TraitClassObjectField extends jet.JetObject {
private object() { /* compiled code */ } private object() { /* compiled code */ }
} }
} }
@@ -1,5 +1,7 @@
// KT-4485 getGenericInterfaces vs getInterfaces for kotlin classes // KT-4485 getGenericInterfaces vs getInterfaces for kotlin classes
import kotlin.jvm.internal.KObject
class SimpleClass class SimpleClass
class ClassWithNonGenericSuperInterface: Cloneable class ClassWithNonGenericSuperInterface: Cloneable
@@ -8,7 +10,7 @@ class ClassWithGenericSuperInterface: java.util.Comparator<String> {
override fun compare(a: String, b: String): Int = 0 override fun compare(a: String, b: String): Int = 0
} }
class ExplicitJetObject: java.util.Comparator<String>, JetObject { class ExplicitKObject: java.util.Comparator<String>, KObject {
override fun compare(a: String, b: String): Int = 0 override fun compare(a: String, b: String): Int = 0
} }
@@ -24,6 +26,6 @@ fun box(): String {
check(javaClass<SimpleClass>()) check(javaClass<SimpleClass>())
check(javaClass<ClassWithNonGenericSuperInterface>()) check(javaClass<ClassWithNonGenericSuperInterface>())
check(javaClass<ClassWithGenericSuperInterface>()) check(javaClass<ClassWithGenericSuperInterface>())
check(javaClass<ExplicitJetObject>()) check(javaClass<ExplicitKObject>())
return "OK" return "OK"
} }
@@ -3,4 +3,4 @@ trait Derived<A>: List<A>
// class: Derived // class: Derived
// jvm signature: Derived // jvm signature: Derived
// generic signature: <A:Ljava/lang/Object;>Ljava/lang/Object;Ljet/JetObject;Ljava/util/List<TA;>; // generic signature: <A:Ljava/lang/Object;>Ljava/lang/Object;Lkotlin/jvm/internal/KObject;Ljava/util/List<TA;>;
@@ -4,4 +4,4 @@ class Derived<A, B, C>: Base<A, B, C>()
// class: Derived // class: Derived
// jvm signature: Derived // jvm signature: Derived
// generic signature: <A:Ljava/lang/Object;B:Ljava/lang/Object;C:Ljava/lang/Object;>LBase<TA;TB;TC;>;Ljet/JetObject; // generic signature: <A:Ljava/lang/Object;B:Ljava/lang/Object;C:Ljava/lang/Object;>LBase<TA;TB;TC;>;Lkotlin/jvm/internal/KObject;
@@ -4,4 +4,4 @@ class Derived<A, B, C>: Base<A, B, C>
// class: Derived // class: Derived
// jvm signature: Derived // jvm signature: Derived
// generic signature: <A:Ljava/lang/Object;B:Ljava/lang/Object;C:Ljava/lang/Object;>Ljava/lang/Object;Ljet/JetObject;LBase<TA;TB;TC;>; // generic signature: <A:Ljava/lang/Object;B:Ljava/lang/Object;C:Ljava/lang/Object;>Ljava/lang/Object;Lkotlin/jvm/internal/KObject;LBase<TA;TB;TC;>;
@@ -5,4 +5,4 @@ class Derived<A, B, C>: Intermediate<Base<A, B, C>>
// class: Derived // class: Derived
// jvm signature: Derived // jvm signature: Derived
// generic signature: <A:Ljava/lang/Object;B:Ljava/lang/Object;C:Ljava/lang/Object;>Ljava/lang/Object;Ljet/JetObject;LIntermediate<LBase<TA;-TB;+TC;>;>; // generic signature: <A:Ljava/lang/Object;B:Ljava/lang/Object;C:Ljava/lang/Object;>Ljava/lang/Object;Lkotlin/jvm/internal/KObject;LIntermediate<LBase<TA;-TB;+TC;>;>;
@@ -235,7 +235,7 @@ public class AnnotationGenTest extends CodegenTestCase {
assertTrue(aClass.isAnnotation()); assertTrue(aClass.isAnnotation());
assertEquals(2, interfaces.length); assertEquals(2, interfaces.length);
assertEquals( assertEquals(
Sets.newHashSet("java.lang.annotation.Annotation", "jet.JetObject"), Sets.newHashSet("java.lang.annotation.Annotation", "kotlin.jvm.internal.KObject"),
Sets.newHashSet(interfaces[0].getName(), interfaces[1].getName()) Sets.newHashSet(interfaces[0].getName(), interfaces[1].getName())
); );
} }
@@ -46,7 +46,7 @@ public final class JvmAbi {
public static final String INSTANCE_FIELD = "instance$"; public static final String INSTANCE_FIELD = "instance$";
public static final String CLASS_OBJECT_FIELD = "object$"; public static final String CLASS_OBJECT_FIELD = "object$";
public static final JvmClassName JET_OBJECT = JvmClassName.byFqNameWithoutInnerClasses("jet.JetObject"); public static final FqName K_OBJECT = new FqName("kotlin.jvm.internal.KObject");
public static boolean isClassObjectFqName(@NotNull FqName fqName) { public static boolean isClassObjectFqName(@NotNull FqName fqName) {
return fqName.lastSegmentIs(Name.identifier(CLASS_OBJECT_CLASS_NAME)); return fqName.lastSegmentIs(Name.identifier(CLASS_OBJECT_CLASS_NAME));
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package jet; package kotlin.jvm.internal;
public interface JetObject { public interface KObject {
} }
@@ -19,7 +19,6 @@ package org.jetbrains.jet.plugin.versions;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module; import com.intellij.openapi.module.Module;
@@ -60,7 +59,6 @@ import java.util.Set;
import static com.intellij.util.PathUtil.getLocalFile; import static com.intellij.util.PathUtil.getLocalFile;
import static com.intellij.util.PathUtil.getLocalPath; import static com.intellij.util.PathUtil.getLocalPath;
import static org.jetbrains.jet.plugin.versions.OutdatedKotlinRuntimeNotification.showRuntimeJarNotFoundDialog; import static org.jetbrains.jet.plugin.versions.OutdatedKotlinRuntimeNotification.showRuntimeJarNotFoundDialog;
public class KotlinRuntimeLibraryUtil { public class KotlinRuntimeLibraryUtil {
@@ -156,12 +154,9 @@ public class KotlinRuntimeLibraryUtil {
ImmutableList<String> candidateClassNames = ImmutableList.of( ImmutableList<String> candidateClassNames = ImmutableList.of(
kotlinPackageClassFqName, kotlinPackageClassFqName,
// For built-ins module in Kotlin project
"jet.Unit", "jet.Unit",
// For older versions // For older versions
"kotlin.namespace", "kotlin.namespace"
// For really old versions
"jet.JetObject"
); );
for (String className : candidateClassNames) { for (String className : candidateClassNames) {