Merge mit bytecode

This commit is contained in:
JanUlrich 2016-04-19 16:59:59 +02:00
commit 07d63a9586
28 changed files with 437 additions and 51 deletions

View File

@ -140,12 +140,17 @@ public class DHBWInstructionFactory extends InstructionFactory{
}
public LocalVariableInstruction createLoad(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
return InstructionFactory.createLoad(bytecodeType, storeIndexes.get(variableName));
return InstructionFactory.createLoad(bytecodeType, getStoreIndex(variableName));
}
public LocalVariableInstruction createStore(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
return InstructionFactory.createStore(bytecodeType, getStoreIndex(variableName));
}
public Integer getStoreIndex(String variableName) {
if(!storeIndexes.containsKey(variableName)){
storeIndexes.put(variableName, storeIndexes.size()+1);
if(storeIndexes.get(variableName) == null){
Integer index = storeIndexes.size()+1;
storeIndexes.put(variableName, index);
}
return storeIndexes.get(variableName);
@ -160,6 +165,6 @@ public class DHBWInstructionFactory extends InstructionFactory{
}
public void resetStoreIndexes() {
storeIndexes = new HashMap<>();
//storeIndexes.clear();
}
}

View File

@ -291,3 +291,4 @@ public class MyCompiler implements MyCompilerAPI{
return ret;
}
}

View File

@ -610,6 +610,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
public void genByteCode(ClassGenerator cg, Class classObj) {
List<TypeinferenceResultSet> typeInterferenceResults = cg.getTypeinferenceResults().getTypeReconstructions(this, cg);
DHBWInstructionFactory _factory = cg.getInstructionFactory();
for(TypeinferenceResultSet t: typeInterferenceResults){
DHBWConstantPoolGen _cp = cg.getConstantPool();
@ -626,6 +627,10 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
for(FormalParameter parameter : this.parameterlist){
argumentTypes[i] = parameter.getType().getBytecodeType(cg, t);
argumentNames[i] = parameter.getIdentifier();
_factory.getStoreIndex(parameter.getIdentifier());
i++;
}
}

View File

@ -39,17 +39,12 @@ import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.typeinference.ByteCodeResult;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.FunNInterface;
import de.dhbwstuttgart.typeinference.FunNMethod;
import de.dhbwstuttgart.typeinference.KomplexeMenge;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResults;
import de.dhbwstuttgart.typeinference.UndConstraint;
import de.dhbwstuttgart.typeinference.UnifyConstraintsSet;
import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
import de.dhbwstuttgart.typeinference.assumptions.ParameterAssumption;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;

View File

@ -169,6 +169,7 @@ public class UnifyTypeFactory {
}
public static Type convert(ReferenceType t) {
//TODO: Hier kann man vielleicht die GTVs extrahieren
RefType ret = new RefType(t.getName(),null,0);
ret.set_ParaList(convert(t.getTypeParams()));
return ret;

View File

@ -3,10 +3,15 @@ package de.dhbwstuttgart.syntaxtree.operator;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.statement.Binary;
import de.dhbwstuttgart.syntaxtree.statement.Expr;
import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
// ino.class.AndOp.24101.declaration
@ -24,6 +29,12 @@ public class AndOp extends LogOp
}
// ino.end
@Override
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
// TODO Auto-generated method stub
return null;
}
}
// ino.end

View File

@ -3,10 +3,22 @@ package de.dhbwstuttgart.syntaxtree.operator;
// ino.end
// ino.module.EqualOp.8597.import
import java.util.Iterator;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.commons.bcel6.Constants;
import org.apache.commons.bcel6.generic.BranchInstruction;
import org.apache.commons.bcel6.generic.GOTO;
import org.apache.commons.bcel6.generic.IF_ICMPNE;
import org.apache.commons.bcel6.generic.InstructionConstants;
import org.apache.commons.bcel6.generic.InstructionList;
import org.apache.commons.bcel6.generic.NOP;
import org.apache.commons.bcel6.generic.ObjectType;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.statement.Binary;
import de.dhbwstuttgart.syntaxtree.statement.Expr;
@ -14,6 +26,8 @@ import de.dhbwstuttgart.syntaxtree.statement.Null;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
@ -32,5 +46,38 @@ public class EqualOp extends RelOp
}
// ino.end
@Override
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
InstructionList linkeSeite = operator.expr1.genByteCode(_cg, rs);
linkeSeite.append(_factory.createInvoke("java.lang.Integer", "intValue", org.apache.commons.bcel6.generic.Type.INT, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
InstructionList rechteSeite = operator.expr2.genByteCode(_cg, rs);
rechteSeite.append(_factory.createInvoke("java.lang.Integer", "intValue", org.apache.commons.bcel6.generic.Type.INT, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
if(operator.getReturnType().getName().equals(new JavaClassName("String"))){
throw new TypeinferenceException("Zeichenketten zusammenfügen ist noch nicht unterstützt",this);
}
linkeSeite.append(rechteSeite);
//TODO: bytecode (Bis jetzt wird jeder Condition als EQUALS behandelt)
//TODO: bytecode autoboxing
BranchInstruction if_icmpneInstruction = new IF_ICMPNE(null);
linkeSeite.append(if_icmpneInstruction);
linkeSeite.append(InstructionConstants.ICONST_1);
BranchInstruction gotoInstruction = new GOTO(null);
linkeSeite.append(gotoInstruction);
if_icmpneInstruction.setTarget(linkeSeite.append(InstructionConstants.ICONST_0));
gotoInstruction.setTarget(linkeSeite.append(_factory.createInvoke("java.lang.Boolean", "valueOf", new ObjectType("java.lang.Boolean"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.BOOLEAN}, Constants.INVOKESTATIC)));
return linkeSeite;
}
}
// ino.end

View File

@ -5,8 +5,11 @@ package de.dhbwstuttgart.syntaxtree.operator;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -19,6 +22,7 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.OderConstraint;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.UndConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
@ -64,6 +68,8 @@ public abstract class Operator extends SyntaxTreeNode
*/
public abstract HashMap<Type,Type> getReturnTypes(TypeAssumptions ass);
public abstract InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator);
@Override
public Menge<SyntaxTreeNode> getChildren() {

View File

@ -2,6 +2,19 @@
package de.dhbwstuttgart.syntaxtree.operator;
// ino.end
import org.apache.commons.bcel6.Constants;
import org.apache.commons.bcel6.generic.BranchInstruction;
import org.apache.commons.bcel6.generic.GOTO;
import org.apache.commons.bcel6.generic.IFEQ;
import org.apache.commons.bcel6.generic.IFNE;
import org.apache.commons.bcel6.generic.InstructionConstants;
import org.apache.commons.bcel6.generic.InstructionList;
import org.apache.commons.bcel6.generic.ObjectType;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
import de.dhbwstuttgart.syntaxtree.statement.Binary;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
// ino.class.OrOp.24282.declaration
public class OrOp extends LogOp
@ -18,5 +31,46 @@ public class OrOp extends LogOp
}
// ino.end
@Override
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
/*
0: aload_1
1: invokevirtual #2 // Method java/lang/Boolean.booleanValue:()Z
4: ifne 14
7: aload_2
8: invokevirtual #2 // Method java/lang/Boolean.booleanValue:()Z
11: ifeq 18
14: iconst_1
15: goto 19
18: iconst_0
19: invokestatic #3 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
22: areturn
*/
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
InstructionList il = operator.get_Expr1().genByteCode(_cg, rs);
il.append(_factory.createInvoke("java.lang.Boolean", "booleanValue", org.apache.commons.bcel6.generic.Type.BOOLEAN, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
BranchInstruction firstTest = new IFNE(null);
il.append(firstTest);
il.append(operator.get_Expr2().genByteCode(_cg, rs));
il.append(_factory.createInvoke("java.lang.Boolean", "booleanValue", org.apache.commons.bcel6.generic.Type.BOOLEAN, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
BranchInstruction secondTest = new IFEQ(null);
il.append(secondTest);
firstTest.setTarget(il.append(InstructionConstants.ICONST_1));
BranchInstruction gotoInstruction = new GOTO(null);
il.append(gotoInstruction);
secondTest.setTarget(il.append(InstructionConstants.ICONST_0));
gotoInstruction.setTarget(il.append(_factory.createInvoke("java.lang.Boolean", "valueOf", new ObjectType("java.lang.Boolean"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.BOOLEAN}, Constants.INVOKESTATIC)));
return il;
}
}
// ino.end

View File

@ -3,10 +3,27 @@ package de.dhbwstuttgart.syntaxtree.operator;
// ino.end
// ino.module.PlusOp.8609.import
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import org.apache.commons.bcel6.Constants;
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
import org.apache.commons.bcel6.generic.BranchInstruction;
import org.apache.commons.bcel6.generic.GOTO;
import org.apache.commons.bcel6.generic.IADD;
import org.apache.commons.bcel6.generic.IFEQ;
import org.apache.commons.bcel6.generic.IFNE;
import org.apache.commons.bcel6.generic.InstructionConstants;
import org.apache.commons.bcel6.generic.InstructionList;
import org.apache.commons.bcel6.generic.InvokeInstruction;
import org.apache.commons.bcel6.generic.ObjectType;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.statement.Binary;
import de.dhbwstuttgart.syntaxtree.statement.Expr;
import de.dhbwstuttgart.syntaxtree.type.Type;
@ -25,5 +42,53 @@ public class PlusOp extends AddOp
}
// ino.end
@Override
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
// TODO Plus Operator ist bis jetzt nur für Integer implementiert
/*
0: aload_1
1: invokevirtual #2 // Method java/lang/Integer.intValue:()I
4: aload_1
5: invokevirtual #2 // Method java/lang/Integer.intValue:()I
8: iadd
9: invokestatic #3 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
12: areturn
*/
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
String returnType = getReturnType(operator.get_Expr1(), operator.get_Expr2());
InstructionList il = getInstructionListForOperand(_cg, rs, operator.get_Expr1(), returnType);
il.append(getInstructionListForOperand(_cg, rs, operator.get_Expr2(), returnType));
il.append(getOperator(returnType));
il.append(convertValueToObject(_factory, returnType));
return il;
}
private String getReturnType(Expr expr1, Expr expr2) {
return "java.lang.Integer";
}
private ArithmeticInstruction getOperator(String returnType) {
return new IADD();
}
private InvokeInstruction convertValueToObject(DHBWInstructionFactory _factory, String returnType) {
if(returnType.equals("java.lang.Integer")){
return _factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.INT}, Constants.INVOKESTATIC);
}else{
throw new NotImplementedException();
}
}
private InstructionList getInstructionListForOperand(ClassGenerator _cg, TypeinferenceResultSet rs, Expr operand, String returnType){
InstructionList il = new InstructionList();
il.append(operand.genByteCode(_cg, rs));
il.append(_cg.getInstructionFactory().createInvoke("java.lang.Integer", "intValue", org.apache.commons.bcel6.generic.Type.INT, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
return il;
}
}
// ino.end

View File

@ -207,7 +207,7 @@ public class Assign extends Expr
}
*/
//Es wird momentan immer von RefType ausgegangen:
il.append(new ASTORE(_factory.getStoreIndex(expr1.get_Name())));
il.append(_factory.createStore(expr2.getType().getBytecodeType(cg, rs), expr1.get_Name()));
return il;
}

View File

@ -227,27 +227,7 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
@Override
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
InstructionList linkeSeite = this.expr1.genByteCode(_cg, rs);
InstructionList rechteSeite = this.expr2.genByteCode(_cg, rs);
if(this.getReturnType().getName().equals(new JavaClassName("String"))){
throw new TypeinferenceException("Zeichenketten zusammenfügen ist noch nicht unterstützt",this);
}
linkeSeite.append(rechteSeite);
//TODO: bytecode (Bis jetzt wird jeder Condition als EQUALS behandelt)
//TODO: bytecode autoboxing
BranchInstruction if_icmpneInstruction = new IF_ICMPNE(null);
linkeSeite.append(if_icmpneInstruction);
linkeSeite.append(InstructionConstants.ICONST_1);
BranchInstruction gotoInstruction = new GOTO(null);
linkeSeite.append(gotoInstruction);
if_icmpneInstruction.setTarget(linkeSeite.append(InstructionConstants.ICONST_0));
gotoInstruction.setTarget(linkeSeite.append(new NOP()));
return linkeSeite;
return op.genByteCode(_cg, rs, this);
}
}

View File

@ -376,7 +376,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable
@Override
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
// TODO Auto-generated method stub
_cg.getInstructionFactory().getStoreIndex(get_Name());
return new InstructionList();
}
}

View File

@ -326,6 +326,7 @@ public class MethodCall extends Expr
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
InstructionList il = new InstructionList();
DHBWInstructionFactory _factory = cg.getInstructionFactory();
//TODO: später wiederherstelln?
_factory.resetStoreIndexes();
il.append(receiver.get_Expr().genByteCode(cg, rs));

View File

@ -56,10 +56,7 @@ public abstract class ASTBytecodeTest {
String rootDirectory = getRootDirectory();
System.out.println(rootDirectory);
JavaClass javaClass = result.getByteCode().getJavaClass();
System.out.println(javaClass.toString());
javaClass.dump(new File(rootDirectory+javaClass.getClassName()+".class"));
for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){
@ -68,7 +65,6 @@ public abstract class ASTBytecodeTest {
}
}catch(Exception e){
System.out.print(e.getMessage());
throw new RuntimeException(e);
}
}
@ -91,8 +87,4 @@ public abstract class ASTBytecodeTest {
public String getTestName() {
return "No Testname defined!";
}
}

View File

@ -0,0 +1,18 @@
class MethodAndVariable{
public Integer method(Integer parameter){
Integer lokaleVariable;
lokaleVariable = 2;
Integer lokaleVariable2;
lokaleVariable2 = method2(lokaleVariable);
return parameter+lokaleVariable2;
}
public Integer method2(Integer parameter){
Integer lokaleVariable;
lokaleVariable = 2;
return parameter+lokaleVariable;
}
}

View File

@ -0,0 +1,26 @@
package bytecode;
import static org.junit.Assert.*;
import org.junit.Test;
import bytecode.SourceFileBytecodeTest;
public class MethodsAndVariableTest extends SourceFileBytecodeTest{
@Override
protected void init() {
testName = "MethodAndVariable";
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
}
@Test
public void testConstruct() throws Exception{
ClassLoader classLoader = getClassLoader();
Class cls = classLoader.loadClass(testName);
Object obj = cls.newInstance();
assertTrue(true);
}
}

View File

@ -0,0 +1,8 @@
class Variable{
public Integer method(Integer parameter){
Integer lokaleVariable;
lokaleVariable = 2;
return parameter+lokaleVariable;
}
}

View File

@ -0,0 +1,35 @@
package bytecode;
import static org.junit.Assert.*;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Vector;
import org.junit.Test;
import org.junit.Ignore;
import bytecode.SourceFileBytecodeTest;
public class VariableTest extends SourceFileBytecodeTest{
@Override
protected void init() {
testName = "Variable";
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
}
@Test
public void testConstruct() throws Exception{
ClassLoader classLoader = getClassLoader();
Class cls = classLoader.loadClass(testName);
Object obj = cls.newInstance();
assertTrue(true);
}
}

View File

@ -0,0 +1,5 @@
class AddOperator{
Integer method(Integer x, Integer y){
return x + y;
}
}

View File

@ -0,0 +1,53 @@
package bytecode.operators;
import static org.junit.Assert.*;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Vector;
import org.junit.Ignore;
import org.junit.Test;
import bytecode.SourceFileBytecodeTest;
public class AddOperatorTest extends SourceFileBytecodeTest{
@Override
protected void init() {
testName = "AddOperator";
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
}
@Test
public void testConstruct() throws Exception{
ClassLoader classLoader = getClassLoader();
Class cls = classLoader.loadClass(testName);
Object obj = cls.newInstance();
assertTrue(true);
}
@Test
public void testTwoIntegers() throws Exception{
ClassLoader classLoader = getClassLoader();
Class cls = classLoader.loadClass(testName);
Object obj = cls.newInstance();
Integer x = new Integer(1);
Integer y = new Integer(2);
Class[] params = new Class[]{
x.getClass(),
y.getClass(),
};
Method method = cls.getDeclaredMethod("method", params);
Integer returnValue = (Integer) method.invoke(obj, x, y);
assertEquals(new Integer(3), returnValue);
}
}

View File

@ -0,0 +1,5 @@
class EqualOperator{
Boolean method(Integer x, Integer y){
return x == y;
}
}

View File

@ -0,0 +1,32 @@
package bytecode.operators;
import static org.junit.Assert.*;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Vector;
import org.junit.Ignore;
import org.junit.Test;
import bytecode.SourceFileBytecodeTest;
public class EqualOperatorTest extends SourceFileBytecodeTest{
@Override
protected void init() {
testName = "EqualOperator";
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
}
@Test
public void testConstruct() throws Exception{
ClassLoader classLoader = getClassLoader();
Class cls = classLoader.loadClass(testName);
Object obj = cls.newInstance();
assertTrue(true);
}
}

View File

@ -0,0 +1,32 @@
package bytecode.operators;
import static org.junit.Assert.*;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Vector;
import org.junit.Ignore;
import org.junit.Test;
import bytecode.SourceFileBytecodeTest;
public class OROperatorTest extends SourceFileBytecodeTest{
@Override
protected void init() {
testName = "OrOperator";
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
}
@Test
public void testConstruct() throws Exception{
ClassLoader classLoader = getClassLoader();
Class cls = classLoader.loadClass(testName);
Object obj = cls.newInstance();
assertTrue(true);
}
}

View File

@ -0,0 +1,5 @@
class OrOperator{
Boolean method(Boolean x, Boolean y){
return x || y;
}
}

View File

@ -33,13 +33,13 @@ public class OLTest extends SourceFileBytecodeTest{
URL url = file.toURL();
URL[] urls = new URL[]{url};
Class stringVector = classLoader.loadClass("Integer");
Integer integer = new Integer(1);
Class[] params = new Class[1];
params[0] = stringVector;
params[0] = integer.getClass();
Method method = cls.getDeclaredMethod("m", params);
method.invoke(obj, stringVector.newInstance());
method.invoke(obj, integer);
assertTrue(true);
}catch(Exception e){
throw new RuntimeException(e);
@ -59,13 +59,13 @@ public class OLTest extends SourceFileBytecodeTest{
URL url = file.toURL();
URL[] urls = new URL[]{url};
Class stringVector = classLoader.loadClass("Boolean");
Boolean bool = new Boolean(true);
Class[] params = new Class[1];
params[0] = stringVector;
params[0] = bool.getClass();
Method method = cls.getDeclaredMethod("m", params);
method.invoke(obj, stringVector.newInstance());
method.invoke(obj, bool);
assertTrue(true);
}catch(Exception e){
throw new RuntimeException(e);

View File

@ -11,7 +11,11 @@ class Overloading{
}
main(String[] args) {
new Overloading().method(new Vector<String> ());
ol;
ol = new Overloading();
v;
v = new Vector<String> ();
ol.method(v);
}
}