mirror of
https://github.com/corda/corda.git
synced 2024-12-25 07:31:10 +00:00
Reformat files in experimental
This commit is contained in:
parent
551dc43265
commit
b1fb321230
@ -32,7 +32,7 @@ fun recordUsedInstrumentedCallStack() {
|
|||||||
val throwable = Throwable()
|
val throwable = Throwable()
|
||||||
var index = 0
|
var index = 0
|
||||||
while (true) {
|
while (true) {
|
||||||
require (index < throwable.stackTrace.size) { "Can't find getStack call" }
|
require(index < throwable.stackTrace.size) { "Can't find getStack call" }
|
||||||
val stackElement = throwable.stackTrace[index]
|
val stackElement = throwable.stackTrace[index]
|
||||||
if (stackElement.className == "co.paralleluniverse.fibers.Stack" && stackElement.methodName == "getStack") {
|
if (stackElement.className == "co.paralleluniverse.fibers.Stack" && stackElement.methodName == "getStack") {
|
||||||
break
|
break
|
||||||
@ -129,7 +129,7 @@ class QuasarInstrumentationHookAgent {
|
|||||||
// The separator append is a hack, it causes a package with an empty name to be added to the exclude tree,
|
// The separator append is a hack, it causes a package with an empty name to be added to the exclude tree,
|
||||||
// which practically causes that level of the tree to be always expanded in the output globs.
|
// which practically causes that level of the tree to be always expanded in the output globs.
|
||||||
val expand = arguments.expand?.let { PackageTree.fromStrings(it.map { "$it${arguments.separator}" }, arguments.separator) }
|
val expand = arguments.expand?.let { PackageTree.fromStrings(it.map { "$it${arguments.separator}" }, arguments.separator) }
|
||||||
val truncatedTree = truncate?.let { scannedTree.truncate(it)} ?: scannedTree
|
val truncatedTree = truncate?.let { scannedTree.truncate(it) } ?: scannedTree
|
||||||
val expandedTree = expand?.let { alwaysExcludedTree.merge(it) } ?: alwaysExcludedTree
|
val expandedTree = expand?.let { alwaysExcludedTree.merge(it) } ?: alwaysExcludedTree
|
||||||
val globs = truncatedTree.toGlobs(expandedTree)
|
val globs = truncatedTree.toGlobs(expandedTree)
|
||||||
globs.forEach {
|
globs.forEach {
|
||||||
@ -271,6 +271,7 @@ data class PackageTree(val branches: Map<String, PackageTree>) {
|
|||||||
val exclude: PackageTree,
|
val exclude: PackageTree,
|
||||||
val globSoFar: List<String>
|
val globSoFar: List<String>
|
||||||
)
|
)
|
||||||
|
|
||||||
val toExpandList = LinkedList(listOf(State(this, excludeTree, emptyList())))
|
val toExpandList = LinkedList(listOf(State(this, excludeTree, emptyList())))
|
||||||
val globs = ArrayList<Glob>()
|
val globs = ArrayList<Glob>()
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -43,7 +43,6 @@ public class CandidacyStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param signature
|
* @param signature
|
||||||
* @return true if the input was absent from the underlying map
|
* @return true if the input was absent from the underlying map
|
||||||
*/
|
*/
|
||||||
@ -52,7 +51,6 @@ public class CandidacyStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param methodSignature
|
* @param methodSignature
|
||||||
* @return true if the input was absent from the underlying map
|
* @return true if the input was absent from the underlying map
|
||||||
*/
|
*/
|
||||||
|
@ -6,15 +6,14 @@ import java.util.Set;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A candidate method that is under evaluation. Candidate methods have one of the following states:
|
* A candidate method that is under evaluation. Candidate methods have one of the following states:
|
||||||
*
|
* <p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link CandidateMethod.State#DETERMINISTIC} - It's deterministic and therefore is allowed to be loaded.</li>
|
* <li>{@link CandidateMethod.State#DETERMINISTIC} - It's deterministic and therefore is allowed to be loaded.</li>
|
||||||
* <li>{@link CandidateMethod.State#DISALLOWED} - It's not deterministic and won't be allowed to be loaded.</li>
|
* <li>{@link CandidateMethod.State#DISALLOWED} - It's not deterministic and won't be allowed to be loaded.</li>
|
||||||
* <li>{@link CandidateMethod.State#SCANNED} - We're not sure if it's deterministic or not.</li>
|
* <li>{@link CandidateMethod.State#SCANNED} - We're not sure if it's deterministic or not.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
* <p>
|
||||||
* CandidateMethods themselves reference other CandidateMethods which are be checked for their deterministic state
|
* CandidateMethods themselves reference other CandidateMethods which are be checked for their deterministic state
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class CandidateMethod {
|
public final class CandidateMethod {
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ public final class CandidateMethod {
|
|||||||
|
|
||||||
public void deterministic() {
|
public void deterministic() {
|
||||||
if (currentState == State.DISALLOWED) {
|
if (currentState == State.DISALLOWED) {
|
||||||
throw new IllegalArgumentException("Method "+ internalMethodName +" attempted to transition from DISALLOWED to DETERMINISTIC");
|
throw new IllegalArgumentException("Method " + internalMethodName + " attempted to transition from DISALLOWED to DETERMINISTIC");
|
||||||
}
|
}
|
||||||
currentState = State.DETERMINISTIC;
|
currentState = State.DETERMINISTIC;
|
||||||
}
|
}
|
||||||
@ -94,6 +93,7 @@ public final class CandidateMethod {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This factory constructor is only called for methods that are known to be deterministic in advance
|
* This factory constructor is only called for methods that are known to be deterministic in advance
|
||||||
|
*
|
||||||
* @param methodSignature
|
* @param methodSignature
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package net.corda.sandbox;
|
package net.corda.sandbox;
|
||||||
|
|
||||||
import static net.corda.sandbox.Utils.*;
|
import static net.corda.sandbox.Utils.*;
|
||||||
|
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author ben
|
* @author ben
|
||||||
*/
|
*/
|
||||||
public final class SandboxAwareClassWriter extends ClassWriter {
|
public final class SandboxAwareClassWriter extends ClassWriter {
|
||||||
@ -26,10 +26,8 @@ public final class SandboxAwareClassWriter extends ClassWriter {
|
|||||||
* that is currently being generated by this ClassWriter, which can of
|
* that is currently being generated by this ClassWriter, which can of
|
||||||
* course not be loaded since it is under construction.
|
* course not be loaded since it is under construction.
|
||||||
*
|
*
|
||||||
* @param type1
|
* @param type1 the internal name of a class.
|
||||||
* the internal name of a class.
|
* @param type2 the internal name of another class.
|
||||||
* @param type2
|
|
||||||
* the internal name of another class.
|
|
||||||
* @return the internal name of the common super class of the two given
|
* @return the internal name of the common super class of the two given
|
||||||
* classes.
|
* classes.
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,6 @@ package net.corda.sandbox;
|
|||||||
import org.objectweb.asm.commons.Remapper;
|
import org.objectweb.asm.commons.Remapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author ben
|
* @author ben
|
||||||
*/
|
*/
|
||||||
public final class SandboxRemapper extends Remapper {
|
public final class SandboxRemapper extends Remapper {
|
||||||
|
@ -4,7 +4,6 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author ben
|
* @author ben
|
||||||
*/
|
*/
|
||||||
public final class Utils {
|
public final class Utils {
|
||||||
@ -43,6 +42,7 @@ public final class Utils {
|
|||||||
* Helper method that converts from the internal class name format (as used in the
|
* Helper method that converts from the internal class name format (as used in the
|
||||||
* Constant Pool) to a fully-qualified class name. No obvious library method to do this
|
* Constant Pool) to a fully-qualified class name. No obvious library method to do this
|
||||||
* appears to exist, hence this code. If one exists, rip this out.
|
* appears to exist, hence this code. If one exists, rip this out.
|
||||||
|
*
|
||||||
* @param classInternalName
|
* @param classInternalName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -55,7 +55,6 @@ public final class Utils {
|
|||||||
* This method takes in an internal method name but needs to return a qualified
|
* This method takes in an internal method name but needs to return a qualified
|
||||||
* classname (suitable for loading)
|
* classname (suitable for loading)
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param internalMethodName
|
* @param internalMethodName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -72,6 +71,7 @@ public final class Utils {
|
|||||||
* Helper method that converts from a fully-qualified class name to the internal class
|
* Helper method that converts from a fully-qualified class name to the internal class
|
||||||
* name format (as used in the Constant Pool). No obvious library method to do this
|
* name format (as used in the Constant Pool). No obvious library method to do this
|
||||||
* appears to exist, hence this code. If one exists, rip this out.
|
* appears to exist, hence this code. If one exists, rip this out.
|
||||||
|
*
|
||||||
* @param qualifiedClassName
|
* @param qualifiedClassName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -102,7 +102,6 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param qualifiedTypeName
|
* @param qualifiedTypeName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -131,7 +130,6 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param desc - internal
|
* @param desc - internal
|
||||||
* @return the rewritten desc string
|
* @return the rewritten desc string
|
||||||
*/
|
*/
|
||||||
|
@ -2,6 +2,7 @@ package net.corda.sandbox;
|
|||||||
|
|
||||||
import net.corda.sandbox.visitors.CostInstrumentingMethodVisitor;
|
import net.corda.sandbox.visitors.CostInstrumentingMethodVisitor;
|
||||||
import net.corda.sandbox.visitors.WhitelistCheckingClassVisitor;
|
import net.corda.sandbox.visitors.WhitelistCheckingClassVisitor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -9,13 +10,13 @@ import java.net.URISyntaxException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.objectweb.asm.*;
|
import org.objectweb.asm.*;
|
||||||
import org.objectweb.asm.commons.ClassRemapper;
|
import org.objectweb.asm.commons.ClassRemapper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author ben
|
* @author ben
|
||||||
*/
|
*/
|
||||||
public final class WhitelistClassLoader extends ClassLoader {
|
public final class WhitelistClassLoader extends ClassLoader {
|
||||||
@ -136,7 +137,6 @@ public final class WhitelistClassLoader extends ClassLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param qualifiedClassName
|
* @param qualifiedClassName
|
||||||
* @return a class object that has been whitelist checked and is known to be
|
* @return a class object that has been whitelist checked and is known to be
|
||||||
* deterministic
|
* deterministic
|
||||||
@ -328,6 +328,7 @@ public final class WhitelistClassLoader extends ClassLoader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter method for the reason for failure
|
* Getter method for the reason for failure
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public WhitelistClassloadingException reason() {
|
public WhitelistClassloadingException reason() {
|
||||||
@ -336,6 +337,7 @@ public final class WhitelistClassLoader extends ClassLoader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter method for the method candidacy status
|
* Getter method for the method candidacy status
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public CandidacyStatus getCandidacyStatus() {
|
public CandidacyStatus getCandidacyStatus() {
|
||||||
|
@ -4,7 +4,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author ben
|
* @author ben
|
||||||
*/
|
*/
|
||||||
public class RuntimeCostAccounter {
|
public class RuntimeCostAccounter {
|
||||||
|
@ -2,6 +2,7 @@ package net.corda.sandbox.tools;
|
|||||||
|
|
||||||
import net.corda.sandbox.WhitelistClassLoader;
|
import net.corda.sandbox.WhitelistClassLoader;
|
||||||
import net.corda.sandbox.visitors.SandboxPathVisitor;
|
import net.corda.sandbox.visitors.SandboxPathVisitor;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@ -18,7 +19,6 @@ import joptsimple.OptionSet;
|
|||||||
* This class takes in an exploded set of JRE classes, and a whitelist, and rewrites all
|
* This class takes in an exploded set of JRE classes, and a whitelist, and rewrites all
|
||||||
* classes (note: not methods) that have at least one whitelisted method to create a
|
* classes (note: not methods) that have at least one whitelisted method to create a
|
||||||
* sandboxed version of the class.
|
* sandboxed version of the class.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
// java8.scan.java.lang_and_util java8.interfaces_for_compat java8 sandbox
|
// java8.scan.java.lang_and_util java8.interfaces_for_compat java8 sandbox
|
||||||
public final class SandboxCreator {
|
public final class SandboxCreator {
|
||||||
@ -107,7 +107,6 @@ public final class SandboxCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param basePath
|
* @param basePath
|
||||||
* @param packageName
|
* @param packageName
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
@ -9,7 +9,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author ben
|
* @author ben
|
||||||
*/
|
*/
|
||||||
public final class CostInstrumentingMethodVisitor extends GeneratorAdapter {
|
public final class CostInstrumentingMethodVisitor extends GeneratorAdapter {
|
||||||
@ -36,6 +35,7 @@ public final class CostInstrumentingMethodVisitor extends GeneratorAdapter {
|
|||||||
/**
|
/**
|
||||||
* This method replaces MONITORENTER / MONITOREXIT opcodes with POP - basically
|
* This method replaces MONITORENTER / MONITOREXIT opcodes with POP - basically
|
||||||
* stripping the synchronization out of any sandboxed code.
|
* stripping the synchronization out of any sandboxed code.
|
||||||
|
*
|
||||||
* @param opcode
|
* @param opcode
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -103,7 +103,7 @@ public final class CostInstrumentingMethodVisitor extends GeneratorAdapter {
|
|||||||
/**
|
/**
|
||||||
* This method is called when visiting an opcode with a single operand, that
|
* This method is called when visiting an opcode with a single operand, that
|
||||||
* is a type (represented here as a String).
|
* is a type (represented here as a String).
|
||||||
*
|
* <p>
|
||||||
* For our purposes this is either a NEW opcode or a ANEWARRAY
|
* For our purposes this is either a NEW opcode or a ANEWARRAY
|
||||||
*
|
*
|
||||||
* @param opcode
|
* @param opcode
|
||||||
|
@ -2,8 +2,10 @@ package net.corda.sandbox.visitors;
|
|||||||
|
|
||||||
import net.corda.sandbox.Utils;
|
import net.corda.sandbox.Utils;
|
||||||
import net.corda.sandbox.WhitelistClassLoader;
|
import net.corda.sandbox.WhitelistClassLoader;
|
||||||
|
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -30,7 +32,7 @@ public final class SandboxPathVisitor extends SimpleFileVisitor<Path> {
|
|||||||
public FileVisitResult visitFile(final Path path, final BasicFileAttributes attr) {
|
public FileVisitResult visitFile(final Path path, final BasicFileAttributes attr) {
|
||||||
// Check that this is a class file
|
// Check that this is a class file
|
||||||
if (!path.toString().matches(Utils.CLASSFILE_NAME_SUFFIX)) {
|
if (!path.toString().matches(Utils.CLASSFILE_NAME_SUFFIX)) {
|
||||||
System.out.println("Skipping: "+ path);
|
System.out.println("Skipping: " + path);
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,12 @@ package net.corda.sandbox.visitors;
|
|||||||
|
|
||||||
import net.corda.sandbox.WhitelistClassLoader;
|
import net.corda.sandbox.WhitelistClassLoader;
|
||||||
import net.corda.sandbox.CandidacyStatus;
|
import net.corda.sandbox.CandidacyStatus;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import net.corda.sandbox.CandidateMethod;
|
import net.corda.sandbox.CandidateMethod;
|
||||||
import net.corda.sandbox.Utils;
|
import net.corda.sandbox.Utils;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -14,6 +16,7 @@ import org.objectweb.asm.MethodVisitor;
|
|||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static org.objectweb.asm.Opcodes.*;
|
import static org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +60,7 @@ public final class WhitelistCheckingClassVisitor extends ClassVisitor {
|
|||||||
/**
|
/**
|
||||||
* We initially take the method passed in and store an internal representation of
|
* We initially take the method passed in and store an internal representation of
|
||||||
* the method signature in the our CandidacyStatus working set.
|
* the method signature in the our CandidacyStatus working set.
|
||||||
*
|
* <p>
|
||||||
* We then get an ASM MethodVisitor (which can read the byte code of the method) and pass that to our
|
* We then get an ASM MethodVisitor (which can read the byte code of the method) and pass that to our
|
||||||
* custom method visitor which perform additional checks.
|
* custom method visitor which perform additional checks.
|
||||||
*
|
*
|
||||||
|
@ -13,7 +13,6 @@ import org.objectweb.asm.Label;
|
|||||||
/**
|
/**
|
||||||
* A MethodVisitor which checks method instructions in order to determine if this
|
* A MethodVisitor which checks method instructions in order to determine if this
|
||||||
* method is deterministic or not
|
* method is deterministic or not
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
final class WhitelistCheckingMethodVisitor extends MethodVisitor {
|
final class WhitelistCheckingMethodVisitor extends MethodVisitor {
|
||||||
|
|
||||||
@ -85,14 +84,14 @@ final class WhitelistCheckingMethodVisitor extends MethodVisitor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Currently a no-op.
|
* Currently a no-op.
|
||||||
*
|
* <p>
|
||||||
* The JVMspec seems to permit the possibility of using a backwards branch in a
|
* The JVMspec seems to permit the possibility of using a backwards branch in a
|
||||||
* tableswitch to try to create an infinite loop. However, it seems to be
|
* tableswitch to try to create an infinite loop. However, it seems to be
|
||||||
* impossible in practice - the specification of StackMapFrame seems to prevent
|
* impossible in practice - the specification of StackMapFrame seems to prevent
|
||||||
* it in modern classfile formats, and even by explicitly generating a version
|
* it in modern classfile formats, and even by explicitly generating a version
|
||||||
* 49 (Java 5) classfile, the verifier seems to be specifically resistant to a
|
* 49 (Java 5) classfile, the verifier seems to be specifically resistant to a
|
||||||
* backwards branch from a tableswitch.
|
* backwards branch from a tableswitch.
|
||||||
*
|
* <p>
|
||||||
* We could still add a belt-and-braces static instrumentation to protect
|
* We could still add a belt-and-braces static instrumentation to protect
|
||||||
* against this but it currently seems unnecessary - at worse it is a branch that
|
* against this but it currently seems unnecessary - at worse it is a branch that
|
||||||
* should count against the branch limit, or an explicit disallow of a backwards
|
* should count against the branch limit, or an explicit disallow of a backwards
|
||||||
|
@ -22,7 +22,7 @@ public class TestUtils {
|
|||||||
// Copy resource jar to tmp dir
|
// Copy resource jar to tmp dir
|
||||||
tmpdir = Files.createTempDirectory("wlcl-tmp-test");
|
tmpdir = Files.createTempDirectory("wlcl-tmp-test");
|
||||||
Path copiedJar = tmpdir.resolve("tmp-resource.jar");
|
Path copiedJar = tmpdir.resolve("tmp-resource.jar");
|
||||||
try(final InputStream in = TestUtils.class.getResourceAsStream(resourcePathToJar)) {
|
try (final InputStream in = TestUtils.class.getResourceAsStream(resourcePathToJar)) {
|
||||||
Files.copy(in, copiedJar, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(in, copiedJar, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
final FileSystem fs = FileSystems.newFileSystem(copiedJar, null);
|
final FileSystem fs = FileSystems.newFileSystem(copiedJar, null);
|
||||||
@ -33,7 +33,7 @@ public class TestUtils {
|
|||||||
public static Path copySandboxJarToTmpDir(final String resourcePathToJar) throws IOException {
|
public static Path copySandboxJarToTmpDir(final String resourcePathToJar) throws IOException {
|
||||||
|
|
||||||
Path sandboxJar = tmpdir.resolve("tmp-sandbox.jar");
|
Path sandboxJar = tmpdir.resolve("tmp-sandbox.jar");
|
||||||
try(final InputStream in = TestUtils.class.getResourceAsStream(resourcePathToJar)) {
|
try (final InputStream in = TestUtils.class.getResourceAsStream(resourcePathToJar)) {
|
||||||
Files.copy(in, sandboxJar, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(in, sandboxJar, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
final FileSystem sandboxFs = FileSystems.newFileSystem(sandboxJar, null);
|
final FileSystem sandboxFs = FileSystems.newFileSystem(sandboxJar, null);
|
||||||
@ -46,7 +46,7 @@ public class TestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void cleanupTmpJar() throws IOException {
|
public static void cleanupTmpJar() throws IOException {
|
||||||
for (FileSystem fs: tmpFileSystems) {
|
for (FileSystem fs : tmpFileSystems) {
|
||||||
fs.close();
|
fs.close();
|
||||||
}
|
}
|
||||||
tmpFileSystems.clear();
|
tmpFileSystems.clear();
|
||||||
@ -92,15 +92,15 @@ public class TestUtils {
|
|||||||
// Helper for finding the correct offsets if they change
|
// Helper for finding the correct offsets if they change
|
||||||
public static void printBytes(byte[] data) {
|
public static void printBytes(byte[] data) {
|
||||||
byte[] datum = new byte[1];
|
byte[] datum = new byte[1];
|
||||||
for (int i=0; i < data.length; i++) {
|
for (int i = 0; i < data.length; i++) {
|
||||||
datum[0] = data[i];
|
datum[0] = data[i];
|
||||||
System.out.println(i +" : "+ DatatypeConverter.printHexBinary(datum));
|
System.out.println(i + " : " + DatatypeConverter.printHexBinary(datum));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int findOffset(byte[] classBytes, byte[] originalSeq) {
|
public static int findOffset(byte[] classBytes, byte[] originalSeq) {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for (int i=415; i < classBytes.length; i++) {
|
for (int i = 415; i < classBytes.length; i++) {
|
||||||
if (classBytes[i] != originalSeq[offset]) {
|
if (classBytes[i] != originalSeq[offset]) {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package net.corda.sandbox;
|
package net.corda.sandbox;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
public class WhitelistClassLoaderTest {
|
public class WhitelistClassLoaderTest {
|
||||||
|
@ -11,7 +11,6 @@ import java.util.*;
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author ben
|
* @author ben
|
||||||
*/
|
*/
|
||||||
public class DeterministicClassInstrumenterTest {
|
public class DeterministicClassInstrumenterTest {
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
package net.corda.sandbox.costing;
|
package net.corda.sandbox.costing;
|
||||||
|
|
||||||
import net.corda.sandbox.TestUtils;
|
import net.corda.sandbox.TestUtils;
|
||||||
|
|
||||||
import static net.corda.sandbox.TestUtils.*;
|
import static net.corda.sandbox.TestUtils.*;
|
||||||
|
|
||||||
import net.corda.sandbox.Utils;
|
import net.corda.sandbox.Utils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author ben
|
* @author ben
|
||||||
*/
|
*/
|
||||||
public class SandboxedRewritingTest {
|
public class SandboxedRewritingTest {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package sandbox.greymalkin;
|
package sandbox.greymalkin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author ben
|
* @author ben
|
||||||
*/
|
*/
|
||||||
// Simple hack for now, generalise to lambdas later...
|
// Simple hack for now, generalise to lambdas later...
|
||||||
|
Loading…
Reference in New Issue
Block a user