File tree Expand file tree Collapse file tree 4 files changed +50
-6
lines changed
Expand file tree Collapse file tree 4 files changed +50
-6
lines changed Original file line number Diff line number Diff line change @@ -453,18 +453,18 @@ impl Interpreter {
453453 stack_frame. operand_stack . push ( JavaValue :: Int ( value1 / value2) ) ;
454454 }
455455 Opcode :: IfAcmpeq ( x) => {
456- let value2: Box < dyn ClassInstance > = stack_frame. operand_stack . pop ( ) . unwrap ( ) . into ( ) ;
457- let value1: Box < dyn ClassInstance > = stack_frame. operand_stack . pop ( ) . unwrap ( ) . into ( ) ;
456+ let value2: Option < Box < dyn ClassInstance > > = stack_frame. operand_stack . pop ( ) . unwrap ( ) . into ( ) ;
457+ let value1: Option < Box < dyn ClassInstance > > = stack_frame. operand_stack . pop ( ) . unwrap ( ) . into ( ) ;
458458
459- if value1. equals ( & * value2) ? {
459+ if value1 == value2 {
460460 return Ok ( ExecuteNext :: Jump ( ( current_offset as i32 + * x as i32 ) as u32 ) ) ;
461461 }
462462 }
463463 Opcode :: IfAcmpne ( x) => {
464- let value2: Box < dyn ClassInstance > = stack_frame. operand_stack . pop ( ) . unwrap ( ) . into ( ) ;
465- let value1: Box < dyn ClassInstance > = stack_frame. operand_stack . pop ( ) . unwrap ( ) . into ( ) ;
464+ let value2: Option < Box < dyn ClassInstance > > = stack_frame. operand_stack . pop ( ) . unwrap ( ) . into ( ) ;
465+ let value1: Option < Box < dyn ClassInstance > > = stack_frame. operand_stack . pop ( ) . unwrap ( ) . into ( ) ;
466466
467- if ! value1. equals ( & * value2) ? {
467+ if value1 != value2 {
468468 return Ok ( ExecuteNext :: Jump ( ( current_offset as i32 + * x as i32 ) as u32 ) ) ;
469469 }
470470 }
Original file line number Diff line number Diff line change 1+ a != b
2+ a != c
3+ b != c
4+ a != d
5+ a == e
Original file line number Diff line number Diff line change 1+ class ReferenceCompare {
2+ public static void main (String [] args ) {
3+ ReferenceCompare a = new ReferenceCompare ();
4+ ReferenceCompare b = new ReferenceCompare ();
5+ ReferenceCompare c = null ;
6+ String d = "test" ;
7+ ReferenceCompare e = a ;
8+
9+ if (a == b ) {
10+ System .out .println ("a == b" );
11+ } else {
12+ System .out .println ("a != b" );
13+ }
14+
15+ if (a == c ) {
16+ System .out .println ("a == c" );
17+ } else {
18+ System .out .println ("a != c" );
19+ }
20+
21+ if (b == c ) {
22+ System .out .println ("b == c" );
23+ } else {
24+ System .out .println ("b != c" );
25+ }
26+
27+ if ((Object ) a == d ) {
28+ System .out .println ("a == d" );
29+ } else {
30+ System .out .println ("a != d" );
31+ }
32+
33+ if (a == e ) {
34+ System .out .println ("a == e" );
35+ } else {
36+ System .out .println ("a != e" );
37+ }
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments