Sagewire Logo

Compiler warning Question

4 Message(s) by 3 Author(s) originally posted in java language


From: Jeremy Date:   Wednesday, March 28, 2007
As you can see, My program compiled and run , but I got a warning on that,
and I was wondering what that means? In my program, I used Stringtokenizer
and stack to reverse a string , and I think it has to do with stack?

also how can I recompile with -Xlint ?

Note:StackReverse.JAVA uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Process completed.


From: Lew Date:   Thursday, March 29, 2007
wrote in message :
As you can see, My program compiled and run, but I got a warning on that,



We can not see what you do not show.

and I was wondering what that means? In my program, I used Stringtokenizer



Are you referring to StringTokenizer? If not, you'll need to give us a link
to the docs for what you are talking about. If so, you'll need to spell it
correctly for it to compile.

and stack to reverse a string, and I think it has to do with stack?



What stack implementation are you using?

also how can I recompile with -Xlint ?



Add the -Xlint option to your 'JAVAc' command line.

Note:StackReverse.JAVA uses unchecked or unsafe operations.



This error message comes from using "raw type s", that is, non-generic forms
for classes that were declared generic.

Note: Recompile with -Xlint:unchecked for details.



This compiler option will turn those warnings into specific errors.

Process completed.



But yours is not. You've provided no SSCCE, and a real dearth of details.
There is not enough information here to give any kind of detailed help.

-- Lew


From: Jeremy Date:   Thursday, March 29, 2007
I commented out every block of the code , and I found out this section of
the code was the reason why I got a warning from the compiler.
String text = "ABC stands for Another Bad Creation found in early
1990's";
Stack stack = new Stack();

// this statement will break the string into the words which are
separated by space.
StringTokenizer temp = new StringTokenizer(text);<--- is this the
culprit?

// push all the words to the stack one by one
while (temp.hasMoreTokens())
{
stack.push(temp.nextElement());
}
I'm using JCreater LE and It basically just run and compile the program
wrote in message:
As you can see, My program compiled and run, but I got a warning on that,
We can not see what you do not show.
and I was wondering what that means? In my program, I used
Stringtokenizer
Are you referring to StringTokenizer? If not, you'll need to give us a
link to the docs for what you are talking about. If so, you'll need to
spell it correctly for it to compile.
and stack to reverse a string, and I think it has to do with stack?
What stack implementation are you using?
also how can I recompile with -Xlint ?
Add the -Xlint option to your 'JAVAc' command line.
Note:StackReverse.JAVA uses unchecked or unsafe operations.
This error message comes from using "raw types", that is, non-generic
forms for classes that were declared generic.
Note: Recompile with -Xlint:unchecked for details.
This compiler option will turn those warnings into specific errors.
Process completed.
But yours is not. You've provided no SSCCE, and a real dearth of details.
There is not enough information here to give any kind of detailed help.


>
-- Lew


From: Bart Cremers Date:   Friday, March 30, 2007
wrote in message:
I commented out every block of the code, and I found out this section of
the code was the reason why I got a warning from the compiler.
String text = "ABC stands for Another Bad Creation found in early
1990's";
Stack stack = new Stack();
// this statement will break the string into the words which are
separated by space.
StringTokenizer temp = new StringTokenizer(text);<--- is this the
culprit?
// push all the words to the stack one by one
while (temp.hasMoreTokens())
{
stack.push(temp.nextElement());
}
I'm using JCreater LE and It basically just run and compile the program
from the software, instead of command line.
wrote in message

wrote in message:
As you can see, My program compiled and run, but I got a warning on that,
>
We can not see what you do not show.
and I was wondering what that means? In my program, I used
Stringtokenizer
> Are you referring to StringTokenizer? If not, you'll need to give us a
> link to the docs for what you are talking about. If so, you'll need to
> spell it correctly for it to compile.
and stack to reverse a string, and I think it has to do with stack?
> What stack implementation are you using?
also how can I recompile with -Xlint ?
> Add the -Xlint option to your 'JAVAc' command line.
Note:StackReverse.JAVA uses unchecked or unsafe operations.
> This error message comes from using "raw types", that is, non-generic
> forms for classes that were declared generic.
Note: Recompile with -Xlint:unchecked for details.
> This compiler option will turn those warnings into specific errors.
Process completed.
> But yours is not. You've provided no SSCCE, and a real dearth of details.
> There is not enough information here to give any kind of detailed help.
> -- Lew



The error message comes from using the stack without defining the
generic type of the stack. To get information about this when
compiling the compiler tells you to recompile using the option, so
JAVA -Xlint:unchecked ...

You can easily solve this (but you do not have to, as it is simply a
warning) two ways. Add the annotation @xxxxxxxxxxx("unchecked")
to the method containing the violating code, or infer generic type
arguments on the stack:

Stack<String> stack = new Stack<String>();

Using this you can only add Strings to the stack (enforced at compile
time) and retrieving Strings from the stack can be done without
casting.

Regards,

Bart



Next Message: Little problem with class-variable acces


Blogs related to Compiler warning Question

Java Faqs
6) What are the two parts in executing a Java program and their purposes? Ans: Two parts in executing a Java program are: Java Compiler and Java Interpreter. The Java Compiler is used for compilation and the Java Interpreter is used for ...

.Net Interview Questions-VI
Conclusion. C# is not Java. Only methods in base classes need not override or hide derived methods. All methods in derived classes require to be either defined as new or as override. Know what your doing and look out for compiler warnings.

Java 7 Roundup (Feb 28th)
... annotations specifically for software defect detection. These annotations let you more precisely state the semantics of your code so that the compiler or automated tools could check those semantics and indicate warnings or errors. ...

comp.compilers monthly message and Frequently Asked Questions
The download area of the JavaCC (Java Compiler Compiler) site at https://javacc.dev.java.net/ BSD license) has a folder containing a number of grammars. * Where can I get free versions of yacc and lex ? Vern Paxton's flex is a superior ...

Invasion Of The Dynamic Language Weenies
Therefore I prefer a statically typed language, because I've found that compiler warnings about type mismatches are generally a sign that I've made some programmatic or conceptual error. I haven't written what I intended to. ...

Follow-up on the Java Generics post
I wonder if your compiler of choice makes a difference? I seem to remember Eclipse's JDT compiler having subtle differences from Sun's in regards to edge-case generics/casting scenarios (Sun's being more strict and giving more warnings) ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional