import magic

T

Tim Tyler

Bryce said:
I believe its just a warning, not an error in Eclipse.

It /can/ be an error.

Basically it all depends on whether you have the:

"Compiler -> Unnecessary code -> Unused imports"

....configuration option set to Error, Warning or Ignore.
 
T

Tim Tyler

Roedy Green said:
On 08 Jul 2005 17:16:27 +0200, Tor Iver Wilhelmsen:

if you are bundling up source code to give to someone, you have to
figure out what to include. One starting point is looking at the
aggregate imports of classes you wrote.

In theory, IDEs should do all that for you.

In practice, there are deployment tools that do pretty comprehensive
dependency analysis for class files - and they mean that the programmer
doesn't have to look at import statements - since the tool does it all
for them.

The results of that analysis can be applied pretty directly to the
problem of redistributing project fragements as source code - by
ignoring inner classes, and replacing ".class" files with ".java"
ones.
 
R

Roedy Green

It /can/ be an error.

I am discovering the way you do this is to make it loose to start then
gradually tighten up so that even javadoc flaws count as errors.

I would rather it did something more useful with its list of errors,
sorting them by severity and grouping them so you can easily tell if
you pared it down sufficiently for your current purpose. There is no
point in turning off the messages completely, only to discover later
you have been doing the Javadoc all wrong.


--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
T

Tim Tyler

Roedy Green said:
I am discovering the way you do this is to make it loose to start then
gradually tighten up so that even javadoc flaws count as errors.

FWIW, I have everything permanenetly set to "warn" in the compiler
settings - except "Access to a non-accessible member of an enclosing
type" - which is an *evil* setting - and
"Usage of non-externalised strings" which is just too anal for me.
I would rather it did something more useful with its list of errors,
sorting them by severity and grouping them so you can easily tell if
you pared it down sufficiently for your current purpose.

It /does/ sort by severity - it's just that there are only three categories.

You can filter on the error text - and filter based on the resource
containing the error.

It's good enough for me. My main remaining bitch with Eclipse is
that its editor still sucks - though these days it certainly sucks a
*lot* less than it used to.

Thank goodness they've now dealt with many of the worst of these:

http://www.eclipse.org/eclipse/development/performance/
http://www.eclipse.org/eclipse/development/performance/bloopers.html
 
C

Chris Smith

Roedy Green said:
I am discovering the way you do this is to make it loose to start then
gradually tighten up so that even javadoc flaws count as errors.

I rather prefer for the compiler to continue compiling all valid Java
code. Instead, I prefer to make a lot of things into warnings, and just
take warnings very seriously. That way, for example, I don't have to
fix up all manner of anal-retentive stuff in code copied from this
newsgroup just to get it to compile and reproduce someone's problem!

Unfortunately, Sun screwed up royally with Java 1.5 and generics, and
it's now well-nigh impossible to get a clean build because at some point
you'll need to get a reference of a generic type from a servlet session
or something like that, and there's just no way to do it without a
warning. For the moment, I've turned off the warning for unsafe type
operations just because of this.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
C

Chris Smith

Roedy Green said:
I would rather it did something more useful with its list of errors,
sorting them by severity and grouping them so you can easily tell if
you pared it down sufficiently for your current purpose.

I definitely would like to see you be able to specify a severity level
for each warning, and then sort by that. I might be persuaded to turn
back on the unchecked cast warnings if this were the case. I could set
them to a lower priority because they are often impossible to solve; and
they would no longer prevent me from seeing real, important warnings
such as unused variables or assignments with no effect.

Even better, yacc used to have (and probably still has) a warning that
was impossible to get rid of in many situations, and the tool provided a
mechanism to acknowledge the issue so that it would stop issuing the
warning again until something changed. I didn't like the details of the
situation with yacc (it used the number of warnings, which was
dangerous), but the idea was great. I would love to be able to tell the
compiler (Eclipse, in this case) that I know I have an unchecked cast
and it's okay with me... and then it would shut up until I actually
changed something in that logical area of code -- such as any change to
that line, or a change that modifies the type of the expression that is
assigned or the type of the variable being assigned to.

A feature like that would essentially bail Sun out of the tar pit they
have created with generics. I'd rather avoid a language feature because
I still hope Sun comes to its senses and fixes generics to eliminate
type erasure some time soon.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
D

Dale King

Roedy said:
I understand that I import classes in Java so that it can figure out
if the method signatures on the calls match those off the imported
callees. IT need help finding the packages of the class names I use.

No you don't. Imports have nothing to do with methods (except for the
new static import). You import to tell the compiler how to turn
unqualified class names into qualified class names.
 
R

Roedy Green

No you don't. Imports have nothing to do with methods (except for the
new static import). You import to tell the compiler how to turn
unqualified class names into qualified class names.

But why do you want to do that? -- so that you can find the class
files and then the proper method signatures so you can generate the
correct code.

Your point is taken that all imports do is help find the class file
and let the compiler know which version of a class you mean, e.g.
java.awt.List or java.util.List.

The import does not cause anything to be loaded or compiled.



--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
A

Andrew McDonagh

Roedy said:
But why do you want to do that? -- so that you can find the class
files and then the proper method signatures so you can generate the
correct code.

Your point is taken that all imports do is help find the class file
and let the compiler know which version of a class you mean, e.g.
java.awt.List or java.util.List.

The import does not cause anything to be loaded or compiled.

No, imports have nothing to do with methods, they are purely about
saving us from having to fully qualify every CLASS usage, not the usage
of class's methods.

for example (note no usage of the methods):


without import usage we have to do the following...

public java.net.InetAddress getSomeonesAddress() {
return null;
}



with imports we can simplify...

import Java.net.InetAddress;

public InetAddress getSomeonesAddress() {
return null;
}
 
D

David R Tribble

Tim said:
In theory, IDEs should do all that for you.

A brute-force way of doing this is to dump the contents of the .class
file and look for the names of all the classes embedded within it.

But there should be a standard tool for doing this.

-drt
 
R

Roedy Green

A brute-force way of doing this is to dump the contents of the .class
file and look for the names of all the classes embedded within it.

But there should be a standard tool for doing this.


I have created a crude tool. I use Ant/genjar to build the jar. Then I
use wzunzip -t to give me a directory listing. I am finding manually
maintaining forjar.lists is too tedious. I am just going to give my
users ant build.xmls.


Then I run this Funduc script to tidy it up. You could also work with
the manifest, and prune that.

[Script for Search and Replace]
convert wzunzip to forjar.list
[Options]
Search_subdir=1
Prompt_flag=0
Max Display Chars=512
Show Progress Dialog=1
Count across files=0
Replace Processing=0
Process Binary Files=1
Buffer Size=102400
Num Buffers To Process=0
Output_File=
Show_Files=1
Backup Path=
Before Hit=<
After Hit=>
Max Reg Expr=4000
Write to Backup Dir=0
Unzip Dir=C:\DOCUME~1\ADMINI~1.ROE\LOCALS~1\Temp\
Show Files Without Hits=0
Display Replace String=0
Display File Stats=1
Show File Date and Size=0
Reverse Filters=0
Min Size Filter=0
Max Size Filter=0
Min Date Filter=
Max Date Filter=
Skip Files Mask=0
Ignore Attributes=55
Keep file time stamp=0
One hit=0
Sort File Names=0
Sort Ascending=1
Append to output file=0
[Search]
META-INF\MANIFEST.MF
[Replace]

[Search]
OK
[Replace]

[Search]
testing: com
[Replace]
com
[Search]
\
[Replace]
/
[End of Search and Replace Script]

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
T

Tim Tyler

Roedy Green said:

[needed class files to needed source files - for source distribution?]
A brute-force way of doing this is to dump the contents of the .class
file and look for the names of all the classes embedded within it.

But there should be a standard tool for doing this.

I have created a crude tool. I use Ant/genjar to build the jar. Then I
use wzunzip -t to give me a directory listing. I am finding manually
maintaining forjar.lists is too tedious. I am just going to give my
users ant build.xmls.

Then I run this Funduc script to tidy it up. [...]

You also need something to strip out inner class names, no?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top