Finding raw types in 1.5

C

Chris Smith

I'm trying to convert some code to 1.5 from an earlier version of Java,
and take advantage of generics. Does anyone know of a tool to locate
and list all occurrences of raw types in Java code?

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

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

sks

Chris Smith said:
I'm trying to convert some code to 1.5 from an earlier version of Java,
and take advantage of generics. Does anyone know of a tool to locate
and list all occurrences of raw types in Java code?

Doesn't the compiler kick out a warning if you use raw types ?
 
C

Chris Smith

sks said:
Doesn't the compiler kick out a warning if you use raw types ?

Apparently not. The compiler kicks out a warning if you try to convert
raw types to parameterized types with a cast, or if you interact with
the class in a way that depends on the type parameters. However, there
are still some ways that a raw type can be used that do not trigger a
compiler warning. They do make APIs difficult to use from elsewhere
without warnings, though, so I'd like to catch and fix them as soon as
possible.

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

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

George W. Cherry

Chris Smith said:
I'm trying to convert some code to 1.5 from an earlier version of Java,
and take advantage of generics. Does anyone know of a tool to locate
and list all occurrences of raw types in Java code?

Excuse me, Chris. What's a "raw type". (It sounds
like a sort of vulgar cowboy.)

George
 
A

Ann

Chris Smith said:
I'm trying to convert some code to 1.5 from an earlier version of Java,
and take advantage of generics. Does anyone know of a tool to locate
and list all occurrences of raw types in Java code?

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

"grep -n" works for me.
 
C

Chris Smith

Ann said:
"grep -n" works for me.

Only if you wanted to search individually for each generic class that
your code might use. I have no great desire to do that.

So, does such a tool exist? Thanks to anyone who can help me out.

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

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

Chris Smith

George W. Cherry said:
Excuse me, Chris. What's a "raw type". (It sounds
like a sort of vulgar cowboy.)

In Java 1.5, List is a parameterized type. That means that the right
way to use it is, for example:

List<String> myList = new ArrayList<String>();

However, for backward compatibility, the 1.5 compiler allows the use of
the "raw" List type (and the raw ArrayList class) with the old pre-
generics syntax:

List myList = new ArrayList();

So a raw type is one that's missing its type parameters.

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

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

George W. Cherry

George W. Cherry said:
Excuse me, Chris. What's a "raw type". (It sounds
like a sort of vulgar cowboy.)

George

Okay, I Googled

"raw type" java

and found out that a raw type is a non-parameterized generic
type. For example List<T> is a generic type, whereas List is
a raw type (a generic type stripped of its type parameter). I
also found the following "raw type". This cowboy is another
kind of "raw type". Sorry about this.

A couple traveling cross country decided to stop
for a cup of coffee in a local diner somewhere
in Texas. While they were sitting at a booth
near the counter sipping their coffee, a local
cowboy stumbles in and heads for the closest
stool at the counter. As he lifts his leg over
the stool, he cuts one of the loudest farts ever
heard by a human. The tourist jumps up and yells,
"Sir, how dare you fart before my wife!"

The cowboy stopped, tipped his hat politely
and says, "I'm awful sorry ma'am...I didn't know
we was a takin' turns."
 

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
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top