diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/BothSignatureWriter.java b/compiler/backend/src/org/jetbrains/jet/codegen/BothSignatureWriter.java new file mode 100644 index 00000000000..e63487fc198 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/jet/codegen/BothSignatureWriter.java @@ -0,0 +1,211 @@ +package org.jetbrains.jet.codegen; + +import org.jetbrains.annotations.Nullable; +import org.objectweb.asm.Type; +import org.objectweb.asm.signature.SignatureVisitor; +import org.objectweb.asm.signature.SignatureWriter; +import org.objectweb.asm.util.CheckSignatureAdapter; + +import java.util.Stack; + +/** + * @author Stepan Koltsov + */ +public class BothSignatureWriter { + + private static final boolean DEBUG_SIGNATURE_WRITER = true; + + enum Mode { + METHOD(CheckSignatureAdapter.METHOD_SIGNATURE), + CLASS(CheckSignatureAdapter.CLASS_SIGNATURE), + ; + + private final int asmType; + + Mode(int asmType) { + this.asmType = asmType; + } + } + + private final SignatureWriter signatureWriter = new SignatureWriter(); + private final SignatureVisitor signatureVisitor; + private final Mode mode; + + public BothSignatureWriter(Mode mode) { + this.mode = mode; + if (DEBUG_SIGNATURE_WRITER) { + signatureVisitor = new CheckSignatureAdapter(mode.asmType, signatureWriter); + } else { + signatureVisitor = signatureWriter; + } + } + + // TODO: ignore when debugging is disabled + private Stack visitors = new Stack(); + + private void push(SignatureVisitor visitor) { + visitors.push(visitor); + } + + private void pop() { + visitors.pop(); + } + + + + private SignatureVisitor signatureVisitor() { + return !visitors.isEmpty() ? visitors.peek() : signatureVisitor; + } + + private void checkTopLevel() { + if (DEBUG_SIGNATURE_WRITER) { + if (!visitors.isEmpty()) { + throw new IllegalStateException(); + } + } + } + + private void checkMode(Mode mode) { + if (DEBUG_SIGNATURE_WRITER) { + if (mode != this.mode) { + throw new IllegalStateException(); + } + } + } + + + /** + * Shortcut + */ + public void writeAsmType(Type asmType) { + switch (asmType.getSort()) { + case Type.OBJECT: + writeClassBegin(asmType.getInternalName()); + writeClassEnd(); + return; + case Type.ARRAY: + writeArrayType(); + writeAsmType(asmType.getElementType()); + writeArrayEnd(); + return; + default: + String descriptor = asmType.getDescriptor(); + if (descriptor.length() != 1) { + throw new IllegalStateException(); + } + signatureVisitor().visitBaseType(descriptor.charAt(0)); + } + } + + public void writeClassBegin(String internalName) { + signatureVisitor().visitClassType(internalName); + } + + public void writeClassEnd() { + signatureVisitor().visitEnd(); + } + + public void writeArrayType() { + push(signatureVisitor().visitArrayType()); + } + + public void writeArrayEnd() { + pop(); + } + + public void writeTypeArgument(char c) { + push(signatureVisitor().visitTypeArgument(c)); + } + + public void writeTypeArgumentEnd() { + pop(); + } + + public void writeTypeVariable(final String name) { + signatureVisitor().visitTypeVariable(name); + } + + public void writeFormalTypeParameter(final String name) { + checkTopLevel(); + + signatureVisitor().visitFormalTypeParameter(name); + } + + public void writeClassBound() { + push(signatureVisitor().visitClassBound()); + } + + public void writeClassBoundEnd() { + pop(); + } + + public void writeInterfaceBound() { + push(signatureVisitor().visitInterfaceBound()); + } + + public void writeInterfaceBoundEnd() { + pop(); + } + + public void writeParameterType() { + push(signatureVisitor().visitParameterType()); + } + + public void writeParameterTypeEnd() { + pop(); + } + + public void writeReturnType() { + push(signatureVisitor().visitReturnType()); + } + + public void writeReturnTypeEnd() { + pop(); + } + + public void writeSuperclass() { + checkTopLevel(); + checkMode(Mode.CLASS); + + push(signatureVisitor().visitSuperclass()); + } + + public void writeSuperclassEnd() { + pop(); + if (!visitors.isEmpty()) { + throw new IllegalStateException(); + } + } + + public void writeInterface() { + checkTopLevel(); + checkMode(Mode.CLASS); + + push(signatureVisitor().visitInterface()); + } + + public void writeInterfaceEnd() { + pop(); + if (!visitors.isEmpty()) { + throw new IllegalStateException(); + } + } + + + + + @Nullable + public String makeJavaString() { + if (!visitors.isEmpty()) { + throw new IllegalStateException(); + } + return signatureWriter.toString(); + } + + @Nullable + public String makeKotlinString() { + // TODO: not implemented yet + return null; + } + +} diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index 0af0a1ef2e8..7d8298b489a 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -6,6 +6,7 @@ import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.OverridingUtil; +import org.jetbrains.jet.lang.resolve.StdlibNames; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeProjection; @@ -16,9 +17,6 @@ import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.commons.InstructionAdapter; import org.objectweb.asm.commons.Method; -import org.objectweb.asm.signature.SignatureVisitor; -import org.objectweb.asm.signature.SignatureWriter; -import org.objectweb.asm.util.CheckSignatureAdapter; import java.util.*; @@ -29,7 +27,9 @@ import java.util.*; */ public class ImplementationBodyCodegen extends ClassBodyCodegen { private JetDelegationSpecifier superCall; - private String superClass = "java/lang/Object"; + private String superClass; + @Nullable // null means java/lang/Object + private JetType superClassType; private final JetTypeMapper typeMapper; private final BindingContext bindingContext; @@ -39,28 +39,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { bindingContext = state.getBindingContext(); } - private Set getSuperInterfaces(JetClassOrObject aClass) { - List delegationSpecifiers = aClass.getDelegationSpecifiers(); - Set superInterfaces = new LinkedHashSet(); - - for (JetDelegationSpecifier specifier : delegationSpecifiers) { - JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference()); - assert superType != null; - ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor(); - if(CodegenUtil.isInterface(superClassDescriptor)) { - superInterfaces.add(typeMapper.getFQName(superClassDescriptor)); - } - } - return superInterfaces; - } - @Override protected void generateDeclaration() { getSuperClass(); - List interfaces = new ArrayList(); - interfaces.add(JetTypeMapper.TYPE_JET_OBJECT.getInternalName()); - interfaces.addAll(getSuperInterfaces(myClass)); + JvmClassSignature signature = signature(); boolean isAbstract = false; boolean isInterface = false; @@ -77,10 +60,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { Opcodes.ACC_PUBLIC | (isAbstract ? Opcodes.ACC_ABSTRACT : 0) | (isInterface ? Opcodes.ACC_INTERFACE : 0/*Opcodes.ACC_SUPER*/), - jvmName(), - genericSignature(), - superClass, - interfaces.toArray(new String[interfaces.size()]) + signature.getName(), + signature.getGenericSignature(), + signature.getSuperclassName(), + signature.getInterfaces().toArray(new String[0]) ); v.visitSource(myClass.getContainingFile().getName(), null); @@ -94,30 +77,57 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { annotationVisitor.visitEnd(); } } + + private JvmClassSignature signature() { + String genericSignature; + List superInterfaces; - @Nullable - private String genericSignature() { - List typeParameters = descriptor.getTypeConstructor().getParameters(); - - SignatureWriter signatureWriter = new SignatureWriter(); - SignatureVisitor signatureVisitor = JetTypeMapper.DEBUG_SIGNATURE_WRITER - ? new CheckSignatureAdapter(CheckSignatureAdapter.CLASS_SIGNATURE, signatureWriter) - : signatureWriter; - for (TypeParameterDescriptor typeParameter : typeParameters) { - signatureVisitor.visitFormalTypeParameter(typeParameter.getName()); - SignatureVisitor classBoundVisitor = signatureVisitor.visitClassBound(); - // TODO: wrong - JetTypeMapper.visitAsmType(classBoundVisitor, JetTypeMapper.TYPE_OBJECT); + { + LinkedHashSet superInterfacesLinkedHashSet = new LinkedHashSet(); + + BothSignatureWriter signatureVisitor = new BothSignatureWriter(BothSignatureWriter.Mode.CLASS); + + + { // type parameters + List typeParameters = descriptor.getTypeConstructor().getParameters(); + typeMapper.writeFormalTypeParameters(typeParameters, signatureVisitor); + } + + + { // superclass + signatureVisitor.writeSuperclass(); + if (superClassType == null) { + signatureVisitor.writeClassBegin(superClass); + signatureVisitor.writeClassEnd(); + } else { + typeMapper.mapType(superClassType, OwnerKind.IMPLEMENTATION, signatureVisitor, true); + } + signatureVisitor.writeSuperclassEnd(); + } + + + { // superinterfaces + superInterfacesLinkedHashSet.add(StdlibNames.JET_OBJECT_INTERNAL); + + for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) { + JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference()); + assert superType != null; + ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor(); + if (CodegenUtil.isInterface(superClassDescriptor)) { + signatureVisitor.writeInterface(); + Type jvmName = typeMapper.mapType(superType, OwnerKind.IMPLEMENTATION, signatureVisitor, true); + signatureVisitor.writeInterfaceEnd(); + superInterfacesLinkedHashSet.add(jvmName.getInternalName()); + } + } + + superInterfaces = new ArrayList(superInterfacesLinkedHashSet); + } + + // TODO: null if class is not generic and does not have generic superclasses + genericSignature = signatureVisitor.makeJavaString(); } - SignatureVisitor superclassSignatureVisitor = signatureVisitor.visitSuperclass(); - // TODO: wrong - superclassSignatureVisitor.visitClassType("java/lang/Object"); - // TODO: add interfaces - superclassSignatureVisitor.visitEnd(); - - // TODO: return null if class is not generic and does not have generic superclasses - - return signatureWriter.toString(); + return new JvmClassSignature(jvmName(), superClass, superInterfaces, genericSignature); } private String jvmName() { @@ -125,6 +135,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { } protected void getSuperClass() { + superClass = "java/lang/Object"; + superClassType = null; + List delegationSpecifiers = myClass.getDelegationSpecifiers(); if(myClass instanceof JetClass && ((JetClass) myClass).isTrait()) @@ -136,6 +149,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { assert superType != null; ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor(); if(!CodegenUtil.isInterface(superClassDescriptor)) { + superClassType = superType; superClass = typeMapper.mapType(superClassDescriptor.getDefaultType(), kind).getInternalName(); superCall = specifier; } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java index d98c928f379..750d036d961 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -18,9 +18,6 @@ import org.jetbrains.jet.lexer.JetTokens; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.commons.Method; -import org.objectweb.asm.signature.SignatureVisitor; -import org.objectweb.asm.signature.SignatureWriter; -import org.objectweb.asm.util.CheckSignatureAdapter; import java.util.*; @@ -165,10 +162,10 @@ public class JetTypeMapper { return mapReturnType(jetType, null); } - @NotNull private Type mapReturnType(final JetType jetType, @Nullable SignatureVisitor signatureVisitor) { + @NotNull private Type mapReturnType(final JetType jetType, @Nullable BothSignatureWriter signatureVisitor) { if (jetType.equals(JetStandardClasses.getUnitType()) || jetType.equals(JetStandardClasses.getNothingType())) { if (signatureVisitor != null) { - signatureVisitor.visitBaseType('V'); + signatureVisitor.writeAsmType(Type.VOID_TYPE); } return Type.VOID_TYPE; } @@ -226,10 +223,10 @@ public class JetTypeMapper { } @NotNull public Type mapType(final JetType jetType) { - return mapType(jetType, (SignatureVisitor) null); + return mapType(jetType, (BothSignatureWriter) null); } - @NotNull private Type mapType(JetType jetType, @Nullable SignatureVisitor signatureVisitor) { + @NotNull private Type mapType(JetType jetType, @Nullable BothSignatureWriter signatureVisitor) { return mapType(jetType, OwnerKind.IMPLEMENTATION, signatureVisitor); } @@ -237,11 +234,11 @@ public class JetTypeMapper { return mapType(jetType, kind, null); } - @NotNull private Type mapType(JetType jetType, OwnerKind kind, @Nullable SignatureVisitor signatureVisitor) { + @NotNull private Type mapType(JetType jetType, OwnerKind kind, @Nullable BothSignatureWriter signatureVisitor) { return mapType(jetType, kind, signatureVisitor, false); } - @NotNull private Type mapType(JetType jetType, OwnerKind kind, @Nullable SignatureVisitor signatureVisitor, boolean boxPrimitive) { + @NotNull public Type mapType(JetType jetType, OwnerKind kind, @Nullable BothSignatureWriter signatureVisitor, boolean boxPrimitive) { Type known = knowTypes.get(jetType); if (known != null) { return mapKnownAsmType(jetType, known, signatureVisitor, boxPrimitive); @@ -260,8 +257,9 @@ public class JetTypeMapper { JetType memberType = jetType.getArguments().get(0).getType(); if (signatureVisitor != null) { - SignatureVisitor arraySignatureVisitor = signatureVisitor.visitArrayType(); - mapType(memberType, kind, arraySignatureVisitor, true); + signatureVisitor.writeArrayType(); + mapType(memberType, kind, signatureVisitor, true); + signatureVisitor.writeArrayEnd(); } if (!isGenericsArray(jetType)) { @@ -284,13 +282,14 @@ public class JetTypeMapper { Type asmType = Type.getObjectType(name + (kind == OwnerKind.TRAIT_IMPL ? "$$TImpl" : "")); if (signatureVisitor != null) { - signatureVisitor.visitClassType(asmType.getInternalName()); + signatureVisitor.writeClassBegin(asmType.getInternalName()); for (TypeProjection proj : jetType.getArguments()) { // TODO: +- - SignatureVisitor argumentSignatureVisitor = signatureVisitor.visitTypeArgument('='); - mapType(proj.getType(), kind, argumentSignatureVisitor, true); + signatureVisitor.writeTypeArgument('='); + mapType(proj.getType(), kind, signatureVisitor, true); + signatureVisitor.writeTypeArgumentEnd(); } - signatureVisitor.visitEnd(); + signatureVisitor.writeClassEnd(); } return asmType; @@ -299,7 +298,7 @@ public class JetTypeMapper { if (descriptor instanceof TypeParameterDescriptor) { if (signatureVisitor != null) { TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) jetType.getConstructor().getDeclarationDescriptor(); - signatureVisitor.visitTypeVariable(typeParameterDescriptor.getName()); + signatureVisitor.writeTypeVariable(typeParameterDescriptor.getName()); } return mapType(((TypeParameterDescriptor) descriptor).getUpperBoundsAsType(), kind); @@ -308,7 +307,7 @@ public class JetTypeMapper { throw new UnsupportedOperationException("Unknown type " + jetType); } - private Type mapKnownAsmType(JetType jetType, Type asmType, @Nullable SignatureVisitor signatureVisitor, boolean genericTypeParameter) { + private Type mapKnownAsmType(JetType jetType, Type asmType, @Nullable BothSignatureWriter signatureVisitor, boolean genericTypeParameter) { if (signatureVisitor != null) { if (genericTypeParameter) { visitAsmType(signatureVisitor, boxType(asmType)); @@ -319,23 +318,8 @@ public class JetTypeMapper { return asmType; } - public static void visitAsmType(SignatureVisitor visitor, Type asmType) { - switch (asmType.getSort()) { - case Type.OBJECT: - visitor.visitClassType(asmType.getInternalName()); - visitor.visitEnd(); - return; - case Type.ARRAY: - SignatureVisitor elementSignatureVisitor = visitor.visitArrayType(); - visitAsmType(elementSignatureVisitor, asmType.getElementType()); - return; - default: - String descriptor = asmType.getDescriptor(); - if (descriptor.length() != 1) { - throw new IllegalStateException(); - } - visitor.visitBaseType(descriptor.charAt(0)); - } + public static void visitAsmType(BothSignatureWriter visitor, Type asmType) { + visitor.writeAsmType(asmType); } public static Type unboxType(final Type type) { @@ -391,8 +375,6 @@ public class JetTypeMapper { return asmType; } - public static final boolean DEBUG_SIGNATURE_WRITER = true; - public CallableMethod mapToCallableMethod(FunctionDescriptor functionDescriptor, boolean superCall, OwnerKind kind) { if(functionDescriptor == null) return null; @@ -456,22 +438,12 @@ public class JetTypeMapper { needGenericSignature = false; } - SignatureWriter signatureWriter = null; - SignatureVisitor signatureVisitor = null; + BothSignatureWriter signatureVisitor = null; if (needGenericSignature) { - signatureWriter = new SignatureWriter(); - signatureVisitor = DEBUG_SIGNATURE_WRITER ? new CheckSignatureAdapter(CheckSignatureAdapter.METHOD_SIGNATURE, signatureWriter) : signatureWriter; + signatureVisitor = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD); } - for (TypeParameterDescriptor typeParameterDescriptor : f.getTypeParameters()) { - if (signatureVisitor != null) { - signatureVisitor.visitFormalTypeParameter(typeParameterDescriptor.getName()); - SignatureVisitor classBoundVisitor = signatureVisitor.visitClassBound(); - // TODO: wrong base - visitAsmType(classBoundVisitor, TYPE_OBJECT); - // TODO: interfaces - } - } + writeFormalTypeParameters(f.getTypeParameters(), signatureVisitor); final ReceiverDescriptor receiverTypeRef = f.getReceiverParameter(); final JetType receiverType = !receiverTypeRef.exists() ? null : receiverTypeRef.getType(); @@ -489,24 +461,98 @@ public class JetTypeMapper { parameterTypes.add(type); } if (receiverType != null) { - parameterTypes.add(mapType(receiverType, signatureVisitor != null ? signatureVisitor.visitParameterType() : null)); + if (signatureVisitor != null) { + signatureVisitor.writeParameterType(); + } + parameterTypes.add(mapType(receiverType, signatureVisitor)); + if (signatureVisitor != null) { + signatureVisitor.writeParameterTypeEnd(); + } } for (TypeParameterDescriptor parameterDescriptor : f.getTypeParameters()) { if(parameterDescriptor.isReified()) { parameterTypes.add(TYPE_TYPEINFO); if (signatureVisitor != null) { - visitAsmType(signatureVisitor.visitParameterType(), TYPE_TYPEINFO); + signatureVisitor.writeParameterType(); + visitAsmType(signatureVisitor, TYPE_TYPEINFO); + signatureVisitor.writeParameterTypeEnd(); } } } for (ValueParameterDescriptor parameter : parameters) { - Type type = mapType(parameter.getOutType(), signatureVisitor != null ? signatureVisitor.visitParameterType() : null); + if (signatureVisitor != null) { + signatureVisitor.writeParameterType(); + } + Type type = mapType(parameter.getOutType(), signatureVisitor); + if (signatureVisitor != null) { + signatureVisitor.writeParameterTypeEnd(); + } valueParameterTypes.add(type); parameterTypes.add(type); } - Type returnType = f instanceof ConstructorDescriptor ? Type.VOID_TYPE : mapReturnType(f.getReturnType(), signatureVisitor != null ? signatureVisitor.visitReturnType() : null); + Type returnType; + if (f instanceof ConstructorDescriptor) { + returnType = Type.VOID_TYPE; + if (signatureVisitor != null) { + signatureVisitor.writeReturnType(); + visitAsmType(signatureVisitor, Type.VOID_TYPE); + signatureVisitor.writeReturnTypeEnd(); + } + } else { + if (signatureVisitor != null) { + signatureVisitor.writeReturnType(); + returnType = mapReturnType(f.getReturnType(), signatureVisitor); + signatureVisitor.writeReturnTypeEnd(); + } + else { + returnType = mapReturnType(f.getReturnType(), null); + } + } Method method = new Method(f.getName(), returnType, parameterTypes.toArray(new Type[parameterTypes.size()])); - return new JvmMethodSignature(method, signatureWriter != null ? signatureWriter.toString() : null); + return new JvmMethodSignature(method, signatureVisitor != null ? signatureVisitor.makeJavaString() : null); + } + + + public void writeFormalTypeParameters(List typeParameters, BothSignatureWriter signatureVisitor) { + if (signatureVisitor == null) { + return; + } + + for (TypeParameterDescriptor typeParameterDescriptor : typeParameters) { + writeFormalTypeParameter(typeParameterDescriptor, signatureVisitor); + } + } + + private void writeFormalTypeParameter(TypeParameterDescriptor typeParameterDescriptor, BothSignatureWriter signatureVisitor) { + signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName()); + + classBound: + { + signatureVisitor.writeClassBound(); + + for (JetType jetType : typeParameterDescriptor.getUpperBounds()) { + if (jetType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) { + if (!CodegenUtil.isInterface(jetType)) { + mapType(jetType, signatureVisitor); + break classBound; + } + } + } + + // "extends Object" seems to be not optional according to ClassFileFormat-Java5.pdf + } + signatureVisitor.writeClassBoundEnd(); + + for (JetType jetType : typeParameterDescriptor.getUpperBounds()) { + if (jetType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) { + if (CodegenUtil.isInterface(jetType)) { + signatureVisitor.writeInterfaceBound(); + mapType(jetType, signatureVisitor); + signatureVisitor.writeInterfaceBoundEnd(); + } + } + } + } public JvmMethodSignature mapSignature(String name, FunctionDescriptor f) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JvmClassSignature.java b/compiler/backend/src/org/jetbrains/jet/codegen/JvmClassSignature.java new file mode 100644 index 00000000000..e866f873f8a --- /dev/null +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JvmClassSignature.java @@ -0,0 +1,36 @@ +package org.jetbrains.jet.codegen; + +import java.util.List; + +/** + * @author Stepan Koltsov + */ +public class JvmClassSignature { + private final String name; + private final String superclassName; + private final List interfaces; + private final String genericSignature; + + public JvmClassSignature(String name, String superclassName, List interfaces, String genericSignature) { + this.name = name; + this.superclassName = superclassName; + this.interfaces = interfaces; + this.genericSignature = genericSignature; + } + + public String getName() { + return name; + } + + public String getSuperclassName() { + return superclassName; + } + + public List getInterfaces() { + return interfaces; + } + + public String getGenericSignature() { + return genericSignature; + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/StdlibNames.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/StdlibNames.java index 5bade930733..3dde936fe39 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/StdlibNames.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/StdlibNames.java @@ -27,6 +27,7 @@ public class StdlibNames { public static final String JET_METHOD_NULLABLE_RETURN_TYPE_FIELD = "nullableReturnType"; + public static final String JET_OBJECT_INTERNAL = "jet/JetObject"; public static final String JET_OBJECT_CLASS = "jet.JetObject"; public static final String JET_OBJECT_DESCRIPTOR = "Ljet/JetObject;"; diff --git a/compiler/testData/compileJavaAgainstKotlin/class/ExtendsAbstractListT.java b/compiler/testData/compileJavaAgainstKotlin/class/ExtendsAbstractListT.java new file mode 100644 index 00000000000..2d1e5d107fc --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/class/ExtendsAbstractListT.java @@ -0,0 +1,6 @@ +class ExtendsAbstractListT { + { + Mine mine = null; + java.util.List list = mine; + } +} diff --git a/compiler/testData/compileJavaAgainstKotlin/class/ExtendsAbstractListT.kt b/compiler/testData/compileJavaAgainstKotlin/class/ExtendsAbstractListT.kt new file mode 100644 index 00000000000..472c847fd89 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/class/ExtendsAbstractListT.kt @@ -0,0 +1 @@ +abstract class Mine() : java.util.AbstractList() diff --git a/compiler/testData/compileJavaAgainstKotlin/class/ImplementsListString.java b/compiler/testData/compileJavaAgainstKotlin/class/ImplementsListString.java new file mode 100644 index 00000000000..699606e6a43 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/class/ImplementsListString.java @@ -0,0 +1,7 @@ + +class PlainExtendsListString { + { + Mine mine = null; + java.util.List list = mine; + } +} diff --git a/compiler/testData/compileJavaAgainstKotlin/class/ImplementsListString.kt b/compiler/testData/compileJavaAgainstKotlin/class/ImplementsListString.kt new file mode 100644 index 00000000000..8de577c0bcc --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/class/ImplementsListString.kt @@ -0,0 +1 @@ +abstract class Mine : java.util.List diff --git a/compiler/testData/compileJavaAgainstKotlin/class/ImplementsMapPP.java b/compiler/testData/compileJavaAgainstKotlin/class/ImplementsMapPP.java new file mode 100644 index 00000000000..5664662764e --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/class/ImplementsMapPP.java @@ -0,0 +1,7 @@ + +class ImplementsMapPP { + { + Mine mine = null; + java.util.Map map = mine; + } +} diff --git a/compiler/testData/compileJavaAgainstKotlin/class/ImplementsMapPP.kt b/compiler/testData/compileJavaAgainstKotlin/class/ImplementsMapPP.kt new file mode 100644 index 00000000000..a973a76c33e --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/class/ImplementsMapPP.kt @@ -0,0 +1 @@ +abstract class Mine : java.util.Map diff --git a/compiler/testData/compileJavaAgainstKotlin/method/QExtendsListString.java b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsListString.java new file mode 100644 index 00000000000..72b7170231a --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsListString.java @@ -0,0 +1,8 @@ + +class Question { + // id2 is to prevent java type parameter type inference + static T id2(T p) { return p; } + { + java.util.List s = id2(namespace.id((jet.typeinfo.TypeInfo) null, null)); + } +} diff --git a/compiler/testData/compileJavaAgainstKotlin/method/QExtendsListString.kt b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsListString.kt new file mode 100644 index 00000000000..40dc99ff079 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsListString.kt @@ -0,0 +1,3 @@ +import java.util.List + +fun > id(p: P1) = p diff --git a/compiler/testData/compileJavaAgainstKotlin/method/QExtendsString.java b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsString.java new file mode 100644 index 00000000000..f525b5923a5 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsString.java @@ -0,0 +1,8 @@ + +class Question { + // id2 is to prevent java type parameter type inference + static T id2(T p) { return p; } + { + String s = id2(namespace.id((jet.typeinfo.TypeInfo) null, null)); + } +} diff --git a/compiler/testData/compileJavaAgainstKotlin/method/QExtendsString.kt b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsString.kt new file mode 100644 index 00000000000..e360425de59 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsString.kt @@ -0,0 +1 @@ +fun id(p: T) = p