Community
Participate
Working Groups
Build Identifier: 20110609-2236 return (a < b) ? 1 : (a > b) -1 : 0; public final test2(int,int) : int ILOAD 1 ILOAD 2 IF_ICMPGE L0 ICONST_1 GOTO L1 L0 FRAME SAME ILOAD 1 ILOAD 2 IF_ICMPLE L2 ICONST_M1 GOTO L1 L2 FRAME SAME ICONST_0 L1 FRAME SAME1 int IRETURN MAXSTACK = 2 MAXLOCALS = 3 should at least return the same bytecode as below (if not better, ternary operator is known to be faster in some languages/platforms) if (a < b) return 1; if (a > b) return -1; return 0; public final test(int,int) : int ILOAD 1 ILOAD 2 IF_ICMPGE L0 ICONST_1 IRETURN L0 FRAME SAME ILOAD 1 ILOAD 2 IF_ICMPLE L1 ICONST_M1 IRETURN L1 FRAME SAME ICONST_0 IRETURN MAXSTACK = 2 MAXLOCALS = 3 Note how there is an extra L2 label and the goto's. Reproducible: Always Steps to Reproduce: 1. Write the Java code in an IF statement. 2. Write the Java code using the ternary operator. 3. Compare the bytecode.
Manoj, Please take a look.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.