Bug 276741 - comparing identical value detection does not work for this
Summary: comparing identical value detection does not work for this
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-18 12:03 EDT by Dani Megert CLA
Modified: 2009-08-04 08:35 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2009-05-18 12:03:35 EDT
I20090515-1143.

Comparing identical value detection does not work for this, i.e.

if (this == this)

is not warned.
Comment 1 Srikanth Sankaran CLA 2009-05-19 03:01:50 EDT
Will investigate this.
Comment 2 Srikanth Sankaran CLA 2009-05-25 07:48:16 EDT
Proposed patch for bug #276740 should also fix this.
Comment 3 Srikanth Sankaran CLA 2009-06-17 02:45:04 EDT
Released for 3.6M1
Comment 4 Frederic Fusier CLA 2009-06-22 11:46:14 EDT
Srikanth,

Using nightly build leads to have 101 additional warnings in org.eclipse.jdt.core.tests.model project while building my workspace...

All these warnings are in ASTTest and ASTParserTest test suites, typically on following lines:
		assertTrue(ASTParser.K_EXPRESSION == 1);
		           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

This sounds a valid test for me, unless I miss something? If so, then this option should be unset on this project to avoid all these noisy warnings...
Comment 5 Dani Megert CLA 2009-06-23 02:33:07 EDT
>                assertTrue(ASTParser.K_EXPRESSION == 1);
>                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>This sounds a valid test for me, unless I miss something?

What does the test do? Verify the value of constants? If so, it makes sense otherwise I don't see the value of such an assert.
Comment 6 Frederic Fusier CLA 2009-06-23 04:09:02 EDT
(In reply to comment #5)
> >                assertTrue(ASTParser.K_EXPRESSION == 1);
> >                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >This sounds a valid test for me, unless I miss something?
> 
> What does the test do? Verify the value of constants? If so, it makes sense
> otherwise I don't see the value of such an assert.
> 
These are typically tests to verify that API constants value are not modified...
Comment 7 Srikanth Sankaran CLA 2009-06-23 05:28:24 EDT
(In reply to comment #4)
> Srikanth,
> Using nightly build leads to have 101 additional warnings in
> org.eclipse.jdt.core.tests.model project while building my workspace...
> All these warnings are in ASTTest and ASTParserTest test suites, typically on
> following lines:
>                 assertTrue(ASTParser.K_EXPRESSION == 1);
>                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This sounds a valid test for me, unless I miss something? 

I have verified that all the 101 additional warnings are correct
and intended to be produced.

For the org.eclipse.jdt.core.tests.model project alone, I am changing
the compiler setting so these warnings are not produced.

Changed project preferences released to HEAD.
Comment 8 MH CLA 2009-07-10 05:46:37 EDT
In Eclipse 3.5 it's still not fixed:

java.lang.Double has a method:

    /**
     * Returns <code>true</code> if the specified number is a
     * Not-a-Number (NaN) value, <code>false</code> otherwise.
     *
     * @param   v   the value to be tested.
     * @return  <code>true</code> if the value of the argument is NaN;
     *          <code>false</code> otherwise.
     */
    static public boolean isNaN(double v) {
	return (v != v);
    }

The "v != v" is NOT marked! 

My custom code

   if (d != d) { //Double.isNaN()

is marked for "d != d" with "Comparing identical expressions"!
Comment 9 Frederic Fusier CLA 2009-07-10 06:25:57 EDT
(In reply to comment #8)
> In Eclipse 3.5 it's still not fixed:
>
Yes, because this bug is targeted 3.6M1. Furthermore, it seems not to be so critical to be backported to 3.5.1 (no data loss, no exceptions), unless you give solid arguments to convince us...
Comment 10 Dani Megert CLA 2009-07-10 09:24:05 EDT
This is definitely not 3.5.1 worthy.
Comment 11 Frederic Fusier CLA 2009-08-04 08:35:58 EDT
Verified for 3.6M1 using build 20090802-2000.