Bytrecodeerzeugung: Aufruf von Methode mit unterschiedliche Typvariablen schlägt fehl #56

Open
opened 2019-11-21 14:46:33 +00:00 by pl · 1 comment
Owner

Für das Programm

import java.lang.Integer;

public class Overloading_Generics {

id (x) { return x; }

//Integer id (Integer x) { return x; }

}

class Overloading_Generics1 {
main(x) {
var olg = new Overloading_Generics();
return olg.id(x);
}
}

klappt der Aufruf olg.id(x); nicht, da die Typen nicht identisch sind.
Problem in Methode areEquals. areEquals prüft nur auf Gleichheit müsste aber auf Instanz prüfen.

Mit match Funktion aus unify versuchen.

javassist.NotFoundException: Method id is not found
at de.dhbwstuttgart.bytecode.utilities.MethodCallHelper.getDesc(MethodCallHelper.java:96)
at de.dhbwstuttgart.bytecode.BytecodeGenMethod.visit(BytecodeGenMethod.java:803)
at de.dhbwstuttgart.syntaxtree.statement.MethodCall.accept(MethodCall.java:35)
at de.dhbwstuttgart.bytecode.BytecodeGenMethod.visit(BytecodeGenMethod.java:1144)
at de.dhbwstuttgart.syntaxtree.statement.Return.accept(Return.java:19)
at de.dhbwstuttgart.bytecode.BytecodeGenMethod.visit(BytecodeGenMethod.java:176)
at de.dhbwstuttgart.syntaxtree.statement.Block.accept(Block.java:29)
at de.dhbwstuttgart.bytecode.BytecodeGenMethod.(BytecodeGenMethod.java:128)
at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:352)
at de.dhbwstuttgart.syntaxtree.Method.accept(Method.java:61)
at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:217)
at de.dhbwstuttgart.syntaxtree.ClassOrInterface.accept(ClassOrInterface.java:114)
at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:137)
at de.dhbwstuttgart.core.JavaTXCompiler.generateBytecode(JavaTXCompiler.java:777)
at de.dhbwstuttgart.core.JavaTXCompiler.generateBytecode(JavaTXCompiler.java:761)
at bytecode.AllgemeinTest.test(AllgemeinTest.java:33)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
olg

Für das Programm import java.lang.Integer; public class Overloading_Generics { id (x) { return x; } //Integer id (Integer x) { return x; } } class Overloading_Generics1 { main(x) { var olg = new Overloading_Generics(); return olg.id(x); } } klappt der Aufruf olg.id(x); nicht, da die Typen nicht identisch sind. Problem in Methode areEquals. areEquals prüft nur auf Gleichheit müsste aber auf Instanz prüfen. Mit match Funktion aus unify versuchen. javassist.NotFoundException: Method id is not found at de.dhbwstuttgart.bytecode.utilities.MethodCallHelper.getDesc(MethodCallHelper.java:96) at de.dhbwstuttgart.bytecode.BytecodeGenMethod.visit(BytecodeGenMethod.java:803) at de.dhbwstuttgart.syntaxtree.statement.MethodCall.accept(MethodCall.java:35) at de.dhbwstuttgart.bytecode.BytecodeGenMethod.visit(BytecodeGenMethod.java:1144) at de.dhbwstuttgart.syntaxtree.statement.Return.accept(Return.java:19) at de.dhbwstuttgart.bytecode.BytecodeGenMethod.visit(BytecodeGenMethod.java:176) at de.dhbwstuttgart.syntaxtree.statement.Block.accept(Block.java:29) at de.dhbwstuttgart.bytecode.BytecodeGenMethod.<init>(BytecodeGenMethod.java:128) at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:352) at de.dhbwstuttgart.syntaxtree.Method.accept(Method.java:61) at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:217) at de.dhbwstuttgart.syntaxtree.ClassOrInterface.accept(ClassOrInterface.java:114) at de.dhbwstuttgart.bytecode.BytecodeGen.visit(BytecodeGen.java:137) at de.dhbwstuttgart.core.JavaTXCompiler.generateBytecode(JavaTXCompiler.java:777) at de.dhbwstuttgart.core.JavaTXCompiler.generateBytecode(JavaTXCompiler.java:761) at bytecode.AllgemeinTest.test(AllgemeinTest.java:33) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) olg
Author
Owner

so funktioniert es auch nicht

import java.lang.Integer;

public class Overloading_Generics {

id (x) { return x; }

//Integer id (Integer x) { return x; }

}

class Overloading_Generics1 {
main(x) {
var olg = new Overloading_Generics();
return olg.id(1);
}
}

so funktioniert es auch nicht import java.lang.Integer; public class Overloading_Generics { id (x) { return x; } //Integer id (Integer x) { return x; } } class Overloading_Generics1 { main(x) { var olg = new Overloading_Generics(); return olg.id(1); } }
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: JavaTX/JavaCompilerCore#56
No description provided.