Remove obsolete DxChecker
This commit is contained in:
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// FILE: J.java
|
// FILE: J.java
|
||||||
|
|||||||
-2
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.test.backend.handlers
|
package org.jetbrains.kotlin.test.backend.handlers
|
||||||
|
|
||||||
import org.jetbrains.kotlin.codegen.D8Checker
|
import org.jetbrains.kotlin.codegen.D8Checker
|
||||||
import org.jetbrains.kotlin.codegen.DxChecker
|
|
||||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
||||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_DEXING
|
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_DEXING
|
||||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.RUN_DEX_CHECKER
|
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.RUN_DEX_CHECKER
|
||||||
@@ -21,7 +20,6 @@ class DxCheckerHandler(testServices: TestServices) : JvmBinaryArtifactHandler(te
|
|||||||
|
|
||||||
override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) {
|
override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) {
|
||||||
if (RUN_DEX_CHECKER !in module.directives || IGNORE_DEXING in module.directives) return
|
if (RUN_DEX_CHECKER !in module.directives || IGNORE_DEXING in module.directives) return
|
||||||
DxChecker.check(info.classFileFactory)
|
|
||||||
D8Checker.check(info.classFileFactory)
|
D8Checker.check(info.classFileFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -315,8 +315,7 @@ public abstract class CodegenTestCase extends KotlinBaseTest<KotlinBaseTest.Test
|
|||||||
boolean ignoreDexing = myFiles.getPsiFiles().stream().anyMatch(
|
boolean ignoreDexing = myFiles.getPsiFiles().stream().anyMatch(
|
||||||
it -> InTextDirectivesUtils.isDirectiveDefined(it.getText(), "IGNORE_DEXING")
|
it -> InTextDirectivesUtils.isDirectiveDefined(it.getText(), "IGNORE_DEXING")
|
||||||
);
|
);
|
||||||
if (verifyWithDex() && DxChecker.RUN_DX_CHECKER && !ignoreDexing) {
|
if (verifyWithDex() && D8Checker.RUN_D8_CHECKER && !ignoreDexing) {
|
||||||
DxChecker.check(classFileFactory);
|
|
||||||
D8Checker.check(classFileFactory);
|
D8Checker.check(classFileFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public class D8Checker {
|
public class D8Checker {
|
||||||
|
|
||||||
|
public static final boolean RUN_D8_CHECKER = true;
|
||||||
|
|
||||||
private D8Checker() {
|
private D8Checker() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.codegen;
|
|
||||||
|
|
||||||
import com.android.dx.cf.direct.DirectClassFile;
|
|
||||||
import com.android.dx.cf.direct.StdAttributeFactory;
|
|
||||||
import com.android.dx.command.dexer.Main;
|
|
||||||
import com.android.dx.dex.cf.CfTranslator;
|
|
||||||
import com.android.dx.dex.file.DexFile;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.kotlin.backend.common.output.OutputFile;
|
|
||||||
import org.jetbrains.kotlin.test.KtAssert;
|
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class DxChecker {
|
|
||||||
|
|
||||||
public static final boolean RUN_DX_CHECKER = true;
|
|
||||||
private static final Pattern STACK_TRACE_PATTERN = Pattern.compile("[\\s]+at .*");
|
|
||||||
|
|
||||||
private DxChecker() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void check(ClassFileFactory outputFiles) {
|
|
||||||
Main.Arguments arguments = new Main.Arguments();
|
|
||||||
String[] array = new String[1];
|
|
||||||
array[0] = "testArgs";
|
|
||||||
arguments.parse(array);
|
|
||||||
|
|
||||||
for (OutputFile file : ClassFileUtilsKt.getClassFiles(outputFiles)) {
|
|
||||||
try {
|
|
||||||
byte[] bytes = file.asByteArray();
|
|
||||||
if (isJava6Class(bytes)) {
|
|
||||||
checkFileWithDx(bytes, file.getRelativePath(), arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable e) {
|
|
||||||
KtAssert.fail(generateExceptionMessage(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isJava6Class(byte[] bytes) throws IOException {
|
|
||||||
try (DataInputStream stream = new DataInputStream(new ByteArrayInputStream(bytes))) {
|
|
||||||
int header = stream.readInt();
|
|
||||||
if (0xCAFEBABE != header) {
|
|
||||||
throw new IOException("Invalid header class header: " + header);
|
|
||||||
}
|
|
||||||
int minor = stream.readUnsignedShort();
|
|
||||||
int major = stream.readUnsignedShort();
|
|
||||||
return major == Opcodes.V1_6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void checkFileWithDx(byte[] bytes, @NotNull String relativePath) {
|
|
||||||
Main.Arguments arguments = new Main.Arguments();
|
|
||||||
String[] array = new String[1];
|
|
||||||
array[0] = "testArgs";
|
|
||||||
arguments.parse(array);
|
|
||||||
checkFileWithDx(bytes, relativePath, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void checkFileWithDx(byte[] bytes, @NotNull String relativePath, @NotNull Main.Arguments arguments) {
|
|
||||||
DirectClassFile cf = new DirectClassFile(bytes, relativePath, true);
|
|
||||||
cf.setAttributeFactory(StdAttributeFactory.THE_ONE);
|
|
||||||
CfTranslator.translate(
|
|
||||||
cf,
|
|
||||||
bytes,
|
|
||||||
arguments.cfOptions,
|
|
||||||
arguments.dexOptions,
|
|
||||||
new DexFile(arguments.dexOptions)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String generateExceptionMessage(Throwable e) {
|
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
try (PrintWriter printWriter = new PrintWriter(writer)) {
|
|
||||||
e.printStackTrace(printWriter);
|
|
||||||
String stackTrace = writer.toString();
|
|
||||||
Matcher matcher = STACK_TRACE_PATTERN.matcher(stackTrace);
|
|
||||||
return matcher.replaceAll("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -39,7 +39,6 @@ class TestStdlibWithDxTest {
|
|||||||
for (entry in generateSequence { zip.nextEntry }) {
|
for (entry in generateSequence { zip.nextEntry }) {
|
||||||
if (entry.name.endsWith(".class") && !entry.name.startsWith("META-INF/")) {
|
if (entry.name.endsWith(".class") && !entry.name.startsWith("META-INF/")) {
|
||||||
val bytes = zip.readBytes()
|
val bytes = zip.readBytes()
|
||||||
DxChecker.checkFileWithDx(bytes, entry.name)
|
|
||||||
files.add(Pair(bytes, entry.name))
|
files.add(Pair(bytes, entry.name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user