Bug 69315 - Deprecated code warnings
Summary: Deprecated code warnings
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-05 14:39 EDT by yoann CLA
Modified: 2004-07-12 17:29 EDT (History)
1 user (show)

See Also:


Attachments
Preference export (39.50 KB, text/plain)
2004-07-05 16:43 EDT, yoann CLA
no flags Details
Preference file - Usage of deprecated API = ERROR (40.67 KB, text/plain)
2004-07-08 01:04 EDT, yoann CLA
no flags Details
Screenshot of compiler preference tab (68.96 KB, image/jpeg)
2004-07-08 01:05 EDT, yoann CLA
no flags Details
System configuration summary (51.84 KB, text/plain)
2004-07-08 11:35 EDT, yoann CLA
no flags Details
Tool to run (76.86 KB, application/octet-stream)
2004-07-12 12:40 EDT, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description yoann CLA 2004-07-05 14:39:18 EDT
Hi,

Eclipse version doesn't report deprecation warning for use of deprecated code 
like JTable.createScrollPaneForTable(aTable) ...
But the 'Check overriding and implementing methods' is working !

Config:
WinXP SP1
J2SDK 1.4.2_05 (1.4.2_04 and 1.4.2_03 as well)
Eclipse 3.0 

No special configuration or plugins.

See bug #48623 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=48623> 
Newsgroup : http://www.eclipse.org/newsportal/article.php?
group=eclipse.tools.jdt&id=%3Cccanv0%242ql%241%40eclipse.org%3E
Comment 1 Philipe Mulet CLA 2004-07-05 15:27:12 EDT
Cannot reproduce. A warning is reported once deprecation is set to warning.

import javax.swing.JTable;
public class X {
	public static void main(String[] args) {
		JTable.createScrollPaneForTable(null);
	}
}

--> The method createScrollPaneForTable(JTable) from the type JTable is 
deprecated

Please export your preferences and attach them to this defect.
Comment 2 Mik Kersten CLA 2004-07-05 16:05:50 EDT
This report is against the AJDT product, but no AspectJ/AJDT version has been 
specified.  And "AJDT" is first in the product list on the submission page...  

Could the reporter please verify whether this problem occurred with the JDT 
Java compiler or with the AJDT AspectJ compiler?

Philippe: if it's against JDT I assume that you'll reassign it.
Comment 3 yoann CLA 2004-07-05 16:40:10 EDT
Yes .... you'll right it's about JDT and not AJDT !

Sorry for misunderstanding :/
Comment 4 yoann CLA 2004-07-05 16:43:55 EDT
Created attachment 12971 [details]
Preference export
Comment 5 Philipe Mulet CLA 2004-07-05 18:04:10 EDT
Moving to AJDT (unsure whether it is AJDT or AspectJ).
Comment 6 Mik Kersten CLA 2004-07-05 19:22:44 EDT
Philippe: In Comment #3 Yoann indicates that this is a JDT bug report, not 
AspectJ/AJDT.  I have moved it to JDT Core and assigned it to you.
Comment 7 Philipe Mulet CLA 2004-07-07 15:36:57 EDT
Your settings indicate you did not enable the deprecation diagnosis. 
In prefs, set 'Usage of deprecated API' to WARNING. 
Comment 8 yoann CLA 2004-07-08 01:03:05 EDT
It was already activated .... it's activated by default ...

So I set 'Usage of deprecated API' to ERROR (see attached files for screenshot 
and re-exported preferences file) !

Could you tell me which key in preferences is missing that allow you to say 
that the wasn't set (maybe by importing a correct preferences file it works)
Comment 9 yoann CLA 2004-07-08 01:04:50 EDT
Created attachment 13042 [details]
Preference file - Usage of deprecated API = ERROR
Comment 10 yoann CLA 2004-07-08 01:05:49 EDT
Created attachment 13043 [details]
Screenshot of compiler preference tab
Comment 11 Philipe Mulet CLA 2004-07-08 06:58:32 EDT
You're right, there is no entry for setting assigned to their defaults. The 
entry I was looking for is:
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.problem.deprecatio
n

Anyway, now that we are sure the compiler is correctly set, suspicion goes 
against the JRE libraries. Would it work better if you did switch to a 
different JDK (for compiling against) ?
Comment 12 yoann CLA 2004-07-08 07:14:35 EDT
I have already tried with 1.4.2_03 and 1.4.2_04 and no deprecation warning 
appears.
(So which JDK are you using ?)

Here a sample class and the command-line cmpilation output :


 CLASS
--------

import javax.swing.JTable;

public class Deprecation
{
	
	static public void main(String[] args)
	{
		JTable.createScrollPaneForTable(null) ;
	}
	
} // end of class


 OUTPUT
---------

C:\dev\projects\samples\src>javac Deprecation.java
Note: Deprecation.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.


C:\dev\projects\samples\src>javac -deprecation Deprecation.java
Deprecation.java:8: warning: createScrollPaneForTable(javax.swing.JTable) in 
jav
ax.swing.JTable has been deprecated
                JTable.createScrollPaneForTable(null) ;
                      ^
1 warning
Comment 13 Philipe Mulet CLA 2004-07-08 09:12:24 EDT
This is the same example I did try (comment #1). It works fine against 
1.4.2_04.
Comment 14 yoann CLA 2004-07-08 10:43:15 EDT
Ok .... I re-tried with M9 and JDK 1.4.2_04 (all combination) and you're 
right, no deprecation warnings !!

Is there a problem I have ANT_HOME, JAVA_HOME and PATH environment variables 
set ??

I change status to INVALID, so if you could just help me to find a way ... thx
Comment 15 Philipe Mulet CLA 2004-07-08 11:14:59 EDT
Are you using the Ant adapter or the plain IDE ?
Comment 16 Olivier Thomann CLA 2004-07-08 11:21:25 EDT
I will investigate.

I'd like to know if you are using the compiler through an ant task or inside the
IDE. Thanks.
Comment 17 yoann CLA 2004-07-08 11:25:05 EDT
I'm using the plain IDE .... nothing else.
Comment 18 yoann CLA 2004-07-08 11:35:44 EDT
Created attachment 13063 [details]
System configuration summary

Removing environment variables don't change anything !

Maybe a real problem on my workstation (see attached file from menu 'Help>About
Eclipse Platform>Configuration details')
Comment 19 Olivier Thomann CLA 2004-07-08 12:04:42 EDT
You are using a JRE (C:\Program Files\Java\j2re1.4.2_05).
I read somewhere that this was a problem (I cannot recall where I read this).
Try to use the corresponding JDK. I will check both.
Let me know if switching to a JDK 1.4.2_05 solved your problem.
Comment 21 yoann CLA 2004-07-08 14:17:40 EDT
THAT'S IT  !!!   ;)

thanks all for interest and helping me.
Comment 22 Olivier Thomann CLA 2004-07-08 14:42:20 EDT
I reopen it. As long as I don't have a good explanation why it is working with
the SDK and not with the JRE, I don't consider this as fixed. 
Comment 23 Olivier Thomann CLA 2004-07-08 14:43:33 EDT
I will investigate the behavior using the JRE as soon as I get it.
Comment 24 Olivier Thomann CLA 2004-07-12 12:16:55 EDT
The only explanation I have in this case is that the method
JTable.createScrollPaneForTable(JTable) is not tagged as deprecated in the JRE
and it is tagged as deprecated in the SDK. We retrieve the deprecation
information from the Deprecated attribute located in the method info. This must
be different!
I will provide you a small tool to check that on your side since I don't have
the JRE. I only have the SDK. Would you run such tool to help us closing this PR?
Comment 25 Olivier Thomann CLA 2004-07-12 12:40:06 EDT
Created attachment 13169 [details]
Tool to run

Run this tool on the two rt.jar file. Here is the way to call it for the SDK:
C:\>java -cp tool.jar test69315.CheckDeprecatedAttribute
C:\jdks\jdk1.4.2_05\jre\lib\rt.jar

I exported a subset of the classes. I hard coded the method name and the class
name. You should get something like:
The method JTable.createScrollPaneForTable(JTable) is deprecated

or:
The method JTable.createScrollPaneForTable(JTable) is not deprecated


For the SDK I have "is deprecated". This was the expected result. If you get
"is not deprecated" for the rt.jar in the JRE, this is a packaging problem with
the JRE and the problem should be reported to Sun.
My guess is that because the JRE is not intended to be used to compile code,
all deprecation attributes have been removed in order to make the rt.jar
smaller.

Could you please add a note to this PR once you got the result?
Comment 26 yoann CLA 2004-07-12 17:21:29 EDT
You're right ... 

Running tool on SDK JRE :
-------------------------
java -cp tool.jar test69315.CheckDeprecatedAttribute C:\jdks\j2sdk1.4.2_05
\jre\lib\rt.jar
The method JTable.createScrollPaneForTable(JTable) is deprecated

Running tool on standard JRE :
------------------------------
java -cp tool.jar test69315.CheckDeprecatedAttribute "C:\Program 
Files\Java\j2re1.4.2_05\lib\rt.jar"
The method JTable.createScrollPaneForTable(JTable) is not deprecated

Just for my information, what's the issue ?
Comment 27 Olivier Thomann CLA 2004-07-12 17:29:07 EDT
Thanks. This confirms what I guessed. The JRE rt.jar doesn't contain any
deprecated attribute. This is the attribute used to find out if a field/a
method/a type is deprecated or not. Because the JRE is not done to be used to
compile code, these attributes are useless.
So there is nothing we can do about it. Please compile your code against
libraries from a SDK not a JRE.
Closing as INVALID since this is not a bug and there is nothing we can do to fix
this issue.
If you have further questions, let me know. Thanks for your help.