Fixing warnings and harness around running Java8 tests and separate JVM tests

This commit is contained in:
Andy Clement
2014-02-26 13:16:57 -08:00
parent b474237898
commit ee3b3acc2f
17 changed files with 30 additions and 22 deletions

View File

@@ -524,7 +524,7 @@ public class ReloadableType {
for (ReloadableType relevantProxy : relevantProxies) {
Class<?>[] interfacesImplementedByProxy = relevantProxy.getClazz().getInterfaces();
// check slashedname correct
@SuppressWarnings("restriction")
// @SuppressWarnings("restriction")
byte[] newProxyBytes = sun.misc.ProxyGenerator.generateProxyClass(relevantProxy.getSlashedName(),
interfacesImplementedByProxy);
relevantProxy.loadNewVersion(versionsuffix, newProxyBytes, true);

View File

@@ -18,7 +18,6 @@ package org.springsource.loaded.agent;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.ProtectionDomain;

View File

@@ -140,7 +140,7 @@ public class EmptyCtor extends ClassVisitor implements Constants {
public void visitIincInsn(int var, int increment) {
}
public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) {
}
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {

View File

@@ -33,7 +33,7 @@ public class JavaMethodInvoker extends Invoker {
private Method method;
public JavaMethodInvoker(@SuppressWarnings("unused") JavaClassMethodProvider provider, Method method) {
public JavaMethodInvoker(/*@SuppressWarnings("unused")*/JavaClassMethodProvider provider, Method method) {
this.method = method;
}

View File

@@ -183,7 +183,7 @@ public class ReflectiveInterceptor {
/*
* Get the Class that declares the method calling interceptor method that called this method.
*/
@SuppressWarnings("restriction")
@SuppressWarnings("deprecation")
public static Class<?> getCallerClass() {
//0 = sun.reflect.Reflection.getCallerClass
//1 = this method's frame

View File

@@ -184,7 +184,7 @@ public class MethodPrinter extends MethodVisitor implements Opcodes {
return null;
}
public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) {
}
public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {

View File

@@ -18,7 +18,6 @@ package org.springsource.loaded.test;
import org.junit.Test;
import org.springsource.loaded.ReloadableType;
import org.springsource.loaded.TypeRegistry;
import org.springsource.loaded.test.infra.ClassPrinter;
/**

View File

@@ -190,7 +190,7 @@ public class ReloadableTypeTests extends SpringLoadedTests {
@Test
public void invokeStaticReloading_gh4_1() throws Exception {
TypeRegistry tr = getTypeRegistry("invokestatic..*");
ReloadableType A = tr.addType("invokestatic.issue4.A", loadBytesForClass("invokestatic.issue4.A"));
tr.addType("invokestatic.issue4.A", loadBytesForClass("invokestatic.issue4.A"));
ReloadableType B = tr.addType("invokestatic.issue4.B", loadBytesForClass("invokestatic.issue4.B"));
Result r = runUnguarded(B.getClazz(), "getMessage");
@@ -315,7 +315,8 @@ public class ReloadableTypeTests extends SpringLoadedTests {
@Test
public void protectedFieldAccessors3() throws Exception {
TypeRegistry tr = getTypeRegistry("prot.SubThree,prot.PeerThree");
ReloadableType rtypePeer = tr.addType("prot.PeerThree", loadBytesForClass("prot.PeerThree"));
// ReloadableType rtypePeer =
tr.addType("prot.PeerThree", loadBytesForClass("prot.PeerThree"));
ReloadableType rtype = tr.addType("prot.SubThree", loadBytesForClass("prot.SubThree"));
Object instance = rtype.getClazz().newInstance();

View File

@@ -20,7 +20,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.StringTokenizer;
import org.springsource.loaded.Utils;
@@ -52,7 +51,7 @@ public class ReloadingJVM {
return s;
}
}
else if (f.getName().startsWith("springloaded") && f.getName().endsWith(".jar") && !f.getName().contains("sources")) {
else if (f.getName().startsWith("springloaded") && f.getName().endsWith(".jar") && !f.getName().contains("sources") && !f.getName().contains("javadoc")) {
return f.getAbsolutePath();
}
}

View File

@@ -91,11 +91,12 @@ public abstract class SpringLoadedTests implements Constants {
protected String AspectjrtJar = "../testdata/aspectjrt.jar";
protected String CodeJar = "../testdata/code.jar";
// TODO [java8] replace this with project dependency when Java8 is out
protected String Java8CodeJar = "../testdata-java8/build/libs/testdata-java8.jar";
protected String Java8CodeJar = findJar("../testdata-java8/build/libs","testdata-java8");
protected String GroovyrtJar = "../testdata-groovy/groovy-all-1.8.6.jar";
protected Result result;
protected TypeRegistry registry;
@Before
public void setup() throws Exception {
SpringLoadedPreProcessor.disabled = true;
@@ -601,6 +602,17 @@ public abstract class SpringLoadedTests implements Constants {
return sb.toString();
}
public static String findJar(String whereToLook, String jarPrefix) {
File dir = new File(whereToLook);
File[] fs = dir.listFiles();
for (File f: fs) {
if (f.getName().startsWith(jarPrefix)) {
return f.toString();
}
}
return null;
}
@SuppressWarnings("unchecked")
protected String toStringField(byte[] classdata, String fieldname) {
StringBuilder sb = new StringBuilder();

View File

@@ -24,8 +24,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.springsource.loaded.test.ReloadingJVM.JVMOutput;
import sun.misc.Cleaner;
/**
* These tests use a harness that forks a JVM with the agent attached, closely simulating a real environment. The
* forked process is running a special class that can be sent commands.
@@ -109,11 +107,13 @@ public class SpringLoadedTestsInSeparateJVM extends SpringLoadedTests {
pause(5);
}
@SuppressWarnings("unused")
private final static void debug() {
jvm.shutdown();
jvm = ReloadingJVM.launch("",true);
}
@SuppressWarnings("unused")
private final static void debug(String options) {
jvm = ReloadingJVM.launch(options,true);
}

View File

@@ -109,7 +109,7 @@ public class FakeMethodVisitor extends MethodVisitor implements Constants {
return null;
}
public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) {
}
public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {

View File

@@ -62,9 +62,7 @@ public class InvokerGenerator {
}
/**
* Get the generated code as a String.
*
* @return
* @return the generated code as a String
*/
public String getCode() {
imports = new HashSet<String>();

View File

@@ -6,7 +6,7 @@ public class HelloWorldClinit002 {
}
static {
int i = 1;
@SuppressWarnings("unused") int i = 1;
int j = 2;
for (int k = 0; k < 5; k++) {
i += j;

View File

@@ -1,6 +1,6 @@
package executor;
@SuppressWarnings("unused")
//@SuppressWarnings("unused")
public interface I2 {
// annotation removed

View File

@@ -17,7 +17,7 @@ public class ClassWithAnnotatedConstructors {
// - constructors with changed annotations
//The annotation will be removed
@SuppressWarnings("unused")
// @SuppressWarnings("unused")
private @AnnoT ClassWithAnnotatedConstructors() {}
//The attribute value will be changed

View File

@@ -4,7 +4,7 @@ import reflection.AnnoT;
import reflection.AnnoT2;
import reflection.AnnoT3;
@SuppressWarnings("unused")
//@SuppressWarnings("unused")
public class ClassTarget003 {
@AnnoT3("field")