Skip to content

Commit d50a531

Browse files
committed
Slightly improve bytecode version check during inline
Add class name to the exception message and provide a system property to disable the check
1 parent cf7f2b7 commit d50a531

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public InlineResult doTransform(@NotNull AnonymousObjectGeneration anonymousObje
8888
reader.accept(new ClassVisitor(InlineCodegenUtil.API, classBuilder.getVisitor()) {
8989
@Override
9090
public void visit(int version, int access, @NotNull String name, String signature, String superName, String[] interfaces) {
91-
InlineCodegenUtil.assertVersionNotGreaterThanJava6(version);
91+
InlineCodegenUtil.assertVersionNotGreaterThanJava6(version, name);
9292
super.visit(version, access, name, signature, superName, interfaces);
9393
}
9494

compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegenUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static SMAPAndMethodNode getMethodNode(
9393
cr.accept(new ClassVisitor(API) {
9494
@Override
9595
public void visit(int version, int access, @NotNull String name, String signature, String superName, String[] interfaces) {
96-
assertVersionNotGreaterThanJava6(version);
96+
assertVersionNotGreaterThanJava6(version, name);
9797
}
9898

9999
@Override
@@ -130,11 +130,11 @@ public void visitLineNumber(int line, @NotNull Label start) {
130130
return new SMAPAndMethodNode(node[0], smap);
131131
}
132132

133-
public static void assertVersionNotGreaterThanJava6(int version) {
133+
public static void assertVersionNotGreaterThanJava6(int version, String internalName) {
134134
// TODO: report a proper diagnostic
135-
if (version > Opcodes.V1_6) {
135+
if (version > Opcodes.V1_6 && !"true".equals(System.getProperty("kotlin.skip.bytecode.version.check"))) {
136136
throw new UnsupportedOperationException(
137-
"Cannot inline bytecode of version " + version + ". " +
137+
"Cannot inline bytecode of class " + internalName + " which has version " + version + ". " +
138138
"This compiler can only inline Java 1.6 bytecode (version " + Opcodes.V1_6 + ")"
139139
);
140140
}

0 commit comments

Comments
 (0)