Falscher Konstruktortyp #57

Open
opened 2019-12-29 19:35:56 +00:00 by pl · 1 comment
Owner
No description provided.
Author
Owner

Für

import java.util.Vector;
import java.lang.Integer;

public class mathStruc {
model;

innerOp = (o) -> (ms) -> new mathStruc<>(o.apply(model,ms.model));

public mathStruc(m) {
	model =m;
}

}

und

//package de.test;

import java.util.Vector;
import java.lang.Integer;
import java.lang.Boolean;

import mathStruc;
import vectorAdd;

public class mathStrucVector {

public main() {
Vector v1 = new Vector();
v1.addElement(2);
v1.addElement(2);
Vector v2 = new Vector();
v2.addElement(3);
v2.addElement(3);

	vectorAdd va = new vectorAdd();

	var ms;
	ms = new mathStruc<>(v1);
	var ms2;
	ms2 = new mathStruc<>(v2);
	var ms3;
	
	//ms3 = ms.innerOp.apply(va.add).apply(ms2);
	//return ms3;

}
}

wird folgneder Bytecode erzeugt

public void main();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=3, locals=6, args_size=1
0: new #12 // class java/util/Vector
3: dup
4: invokespecial #13 // Method java/util/Vector."":()V
7: astore_1
8: aload_1
9: iconst_2
10: invokestatic #19 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
13: invokevirtual #23 // Method java/util/Vector.addElement:(Ljava/lang/Object;)V
16: aload_1
17: iconst_2
18: invokestatic #19 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
21: invokevirtual #23 // Method java/util/Vector.addElement:(Ljava/lang/Object;)V
24: new #12 // class java/util/Vector
27: dup
28: invokespecial #13 // Method java/util/Vector."":()V
31: astore_2
32: aload_2
33: iconst_3
34: invokestatic #19 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
37: invokevirtual #23 // Method java/util/Vector.addElement:(Ljava/lang/Object;)V
40: aload_2
41: iconst_3
42: invokestatic #19 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
45: invokevirtual #23 // Method java/util/Vector.addElement:(Ljava/lang/Object;)V
48: new #25 // class vectorAdd
51: dup
52: invokespecial #26 // Method vectorAdd."":()V
55: astore_3
56: new #28 // class mathStruc
59: dup
60: aload_1
61: invokespecial #31 // Method mathStruc."":(Ljava/util/Vector;)V
64: astore 4
66: new #28 // class mathStruc
69: dup
70: aload_2
71: invokespecial #31 // Method mathStruc."":(Ljava/util/Vector;)V
74: astore 5
76: return
}

In Zeile 61 und 71 müsste
61: invokespecial #25 // Method mathStruc."":(Ljava/lang/Object;)V

   71: invokespecial #25                 // Method mathStruc."<init>":(Ljava/lang/Object;)V

stehen

Für import java.util.Vector; import java.lang.Integer; public class mathStruc { model; innerOp = (o) -> (ms) -> new mathStruc<>(o.apply(model,ms.model)); public mathStruc(m) { model =m; } } und //package de.test; import java.util.Vector; import java.lang.Integer; import java.lang.Boolean; import mathStruc; import vectorAdd; public class mathStrucVector { public main() { Vector<Integer> v1 = new Vector<Integer>(); v1.addElement(2); v1.addElement(2); Vector<Integer> v2 = new Vector<Integer>(); v2.addElement(3); v2.addElement(3); vectorAdd va = new vectorAdd(); var ms; ms = new mathStruc<>(v1); var ms2; ms2 = new mathStruc<>(v2); var ms3; //ms3 = ms.innerOp.apply(va.add).apply(ms2); //return ms3; } } wird folgneder Bytecode erzeugt public void main(); descriptor: ()V flags: (0x0001) ACC_PUBLIC Code: stack=3, locals=6, args_size=1 0: new #12 // class java/util/Vector 3: dup 4: invokespecial #13 // Method java/util/Vector."<init>":()V 7: astore_1 8: aload_1 9: iconst_2 10: invokestatic #19 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 13: invokevirtual #23 // Method java/util/Vector.addElement:(Ljava/lang/Object;)V 16: aload_1 17: iconst_2 18: invokestatic #19 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 21: invokevirtual #23 // Method java/util/Vector.addElement:(Ljava/lang/Object;)V 24: new #12 // class java/util/Vector 27: dup 28: invokespecial #13 // Method java/util/Vector."<init>":()V 31: astore_2 32: aload_2 33: iconst_3 34: invokestatic #19 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 37: invokevirtual #23 // Method java/util/Vector.addElement:(Ljava/lang/Object;)V 40: aload_2 41: iconst_3 42: invokestatic #19 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 45: invokevirtual #23 // Method java/util/Vector.addElement:(Ljava/lang/Object;)V 48: new #25 // class vectorAdd 51: dup 52: invokespecial #26 // Method vectorAdd."<init>":()V 55: astore_3 56: new #28 // class mathStruc 59: dup 60: aload_1 61: invokespecial #31 // Method mathStruc."<init>":(Ljava/util/Vector;)V 64: astore 4 66: new #28 // class mathStruc 69: dup 70: aload_2 71: invokespecial #31 // Method mathStruc."<init>":(Ljava/util/Vector;)V 74: astore 5 76: return } In Zeile 61 und 71 müsste 61: invokespecial #25 // Method mathStruc."<init>":(Ljava/lang/Object;)V 71: invokespecial #25 // Method mathStruc."<init>":(Ljava/lang/Object;)V stehen
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#57
No description provided.