Invalid compiler warning?
I've got:
class A<Type1>
public A<Type1> getValue();
class B<Type1, Type2> extends A<Type1>
public B<Type1, Type2> getValue()
return (B<Type1, Type2>) super.getValue(); // compiler complains of unchecked cast
}Thing is, I really don't see why the above is an unchecked cast. We know that B extends A. When B is constructed, it passes its parameter-types down so when getValue() returns A<Type1> it is really returning a superclass-view of B<Type1, Type2> -- at least that's what I think is going on. Am I wrong?
Gili
Thing is, I really don't see why the above is an
unchecked cast.A.getType returns an A. B.getType returns a B. Just because 'this' is a B doesn't mean that super.getType will return a B.
For example, we could have:
class A
public A getValue()
return new A();
class B extends A
public B getType()
return super.getType();
}Would you expect the above to work?
Similar Messages
-
Can java provide a follow/depend/attatch compiling warning?
I wrote a class called Query.It connect to database and return ResultSet.So user must manually call my method close() to close the ResultSet and Connection, otherwise resource will be avaliable.
But user maybe forget call the close() method.If codes are released,problem will occur.
For this reason I want java provides a compile warning if a important method is not called.
e.g. Codes maybe like this:
/**Start**/
class Query(){
ResultSet getResultSet(DataSource ds){
//Codes get resultset
return ResultSet;
void close() follow getResultSet(DataSource){
//Close databse
//Note: "follow getResultSet(DataSource)" is my idea.
class test{
Query query = new Query();
RsultSet rst = query.getResultSet();
//query.close();//#1
/**End**/
If user forget writing line #1 (to close Database,etc), java compiler will give a warning:
The method close() must follow method getResultSet!
You will get error when running.
Can java provide this function?
Thanks!to mchan0 :
I konw you mean I can copy ResultSet to another Object.But if databse is very very large,ResultSet will use large memory.It is not we want.
e.g. our project database need to store 40,000,000 records.Once load large numbers records,server will crack.
So I can only use ResultSet.
If I wrong,please correct me.
Thanks -
Hi All,
Can any one suggest me.
I have compilation warning .
my code :
K is String type
K key;
key = (K)(key.toString().replace("'", "''"));
warninig :
java:22: warning: [unchecked] unchecked cast
found : java.lang.String
required: K
key = (K)(key.toString().replace("'", "''"));
Please hekp me
Thanks in advanceHere is my code
public class DataMap<K, V> extends HashMap<K,V>
public V put(K key, V value)
if(key == null || value == null) return null;
if(key.getClass() == String.class)
key = (K)(key.toString().replace("'", "''"));
if(value.getClass() == String.class)
value = (V)(value.toString().replace("'", "''"));
return super.put(key, value);
} -
Invalid address warning when send email
hi,
I get "Invalid Address" warning when I send email, I do not use Internet email address format, e.g [email protected], I use my Lotus address format, e.g. CN=abc/OU=abc/O=COM, it will have warning in iphone, may I ask how to disable this email address checking feature in iphone?
ThanksThere is no way that I know of to disable the warning. All email addresses have an "@" format equivalent; see if you can use it. (Even Lotus Notes server knows it).
-
[svn] 3050: Removed compile warning with JDK1.5
Revision: 3050
Author: [email protected]
Date: 2008-08-29 16:48:58 -0700 (Fri, 29 Aug 2008)
Log Message:
Removed compile warning with JDK1.5
Modified Paths:
blazeds/trunk/modules/core/src/java/flex/messaging/io/BeanProxy.javaDid you try this:
http://forum.java.sun.com/thread.jsp?thread=434718&forum=60&message=1964421 -
Odd Safari Issue (Invalid URL warning on common pages)
I recently upgraded to Safari 5 and have had some strange issues since. Several times since the upgrade when I attempt to log into Facebook, Twitter, or even access Yahoo I sometimes get a page that says 'Invalid URL: The URL "/" is invalid. It's followed by a reference # beginning with a 9.
Also, at times when I attempt to access Facebook, I get redirected to sites like MySpace. I never even use myspace so I don't know why this is happening. Same has happened on Twitter where I have been redirected to a random blog. Last night, when attempting to access Yahoo I was redirected to the Internet Movie database. I sometimes use IMDB but have no idea why Safari seems to be redirecting me to random sites when I have the URL entered correctly for the sites I actually want to visit.
Anyone ever have a similar issue regarding the Invalid URL warning or redirection to random pages?Hi and welcome to Apple Discussions...
From the Safari Menu Bar click Safari/Preferences then select the Security tab.
Click: Show Cookies. Delete all Twitter and Facebook cookies. Relaunch Safari.
If you still have problems accessing either site, open Keychain Access (Applications/Utilities) Select Passwords on the left. Delete the Twitter and Facebook keychains. Relaunch Safari and try logging into one of those sites. If you still have problems, delete the, "Safari Forms Autofill" keychain. Relaunch Safari.
I get redirected to sites like MySpace.
Many Safari users (including myself) benefit from using Open DNS Free / Basic to avoid redirects.
Carolyn -
I keep getting an invalid certificate warning while on the internet. This primarily occurs when using Facebook. Cannot find a solution. Any advice or assistance would be appreciated.
Thx for all your help Barry, but none of this worked. One caveat... when resetting, I unchecked "Remove Names & PW's" & "Remove other Autofill form text" because I didn't want to start over will all this.
I suppose I can just tell Safari to trust each site I'm now getting this warning from. It's just puzzling as to why this is happening all of a sudden. -
Invalid compiler control in ".i"
I have the following lines in a header file (line numbers appear on the left):
64#if defined( sparc )
65 #include <sys/types.h>
66 #include <pthread.h>
67#endif
When I compile the program I get the following errors:
"/home/user/include/structure.h", line 65: invalid compiler control in ".i" file
"/home/user/include/structure.h", line 66: invalid compiler control in ".i" file
I've precompiled the code (with -P), and the resulting .i file contains the
lines "#include <sys/types.h>" and "#include <pthread.h>".
What's the deal?The preprocessor requires that the # be the first character in the line. This worked:
#if defined(sparc)
# include <sys/types.h>
# include <pthread.h>
#endif -
PLS-00378: invalid compilation unit Error
The following statement copied from oracle documentation but its raising error, any idea please ?
CREATE FUNCTION getBooks(a clob) RETURN bookset_t;
LINE/COL ERROR
-------- ------------------------------------------------0/0 PLS-00378: invalid compilation unit for this
release of PL/SQL
My Oracle Version is :
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
Best Regards,
LuqmanI presume that you are referring to the example contained in the following link.
http://www.lc.leidenuniv.nl/awcourse/oracle/appdev.920/a96624/08_subs.htm#19677
The example appears incomplete to me. The example does include the definition of the bookset_t type, but there still must be more to the getBooks function and I don't see anything to link the Catalogs table to the bookSet_t type. I have submitted the question to Tom Kyte. When I receive a response, I will provide a link to that response here. -
Dear all,
Can VC++ trigger compile warning msg when hitting the following conditions related to MFC:
CString _str;
if (_str = L"abc") //<--- (should be ==)
if we use some basic type like int or string(STL) to define for the above conditions, VC compiler can trigger warning msg(warning C4706: assignment within conditional expression) under level 4 warning, but not for MFC CString.
Thanks and regards,
Wallace Chan
P.S: We're using VC++ 2003Can VC++ trigger compile warning msg when hitting the following conditions related to MFC:
It would appear not.
CString _str;
if (_str = L"abc") //<--- (should be ==)
if we use some basic type like int or string(STL) to define for the above conditions, VC compiler can trigger warning msg(warning C4706: assignment within conditional expression) under level 4 warning, but not for MFC CString.
It's interesting that std::string gives rise to an error in this
situation (I get a C2451 error with VS2015 CTP), so it'd be neat if
CString did similar.
Can you file a bug/suggestion for this on MS connect
https://connect.microsoft.com/visualStudio/. Post a link back here to
your report so anyone who sees this can easily find it and vote for
it.
Dave -
Hi all,
How do I turn off the compiler warning about unused CSS
styles. I need the solution for both locally compiled SWF and those
compiled in Flex Data Services. flex-config.xml doesn´t have
the node option.
Thanks
DavidThanks Brent for your quick response. That works well with
the compile locally option. I found the solution if you are
compiling with FDS.
Its in the docs under:
Building and Deploying Flex 2 Applications > Building Flex
Applications > Flex 2 SDK and Flex Data Services Configuration
> Flex Data Services configuration
You can change the flex-webtier-config.xml file and turn the
production setting on, or use the queryString parameter
(showAllWarnings=false) if you are just testing.
Cheers
David -
I have very basic program for learnings vectors but keep getting an warning during compilation. The program works fine but just compilation warning comes as below.
Can soneone please advise what this might be and how to fix it.
import java.util.*;
public class vect2
Vector list;
String[] codes = {"aa","bb","cc","dd","ee","ff","gg"};
public vect2() throws Exception
list = new Vector();
System.out.print(" Loading built in codes");
int ch = System.in.read();
for (int i=0; i < codes.length; i++)
addCode(codes);
System.out.println(" ..................done");
System.out.println(" ");
System.out.println(" ");
System.out.println(" Enter to display all codes ");
int ch2 = System.in.read();
for (Iterator ite = list.iterator(); ite.hasNext();)
String output = (String) ite.next();
System.out.print(output+" ");
private void addCode(String code)
if(!list.contains(code))
list.add(code);
public static void main(String[] args) throws Exception
vect2 var1 = new vect2();
System.out.println(" ");
System.out.println(" ");
compilation error
Note: vect2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint: unchecked for details.
javac -Xlint vect2.java
vect2.java:35: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
list.add(code);
1 warningDouble post.
http://forum.java.sun.com/thread.jspa?threadID=781067
~ -
Hello.
I'm getting such warnings on server startup:
12:57:33,241 WARN [StoreRepository] Warning - table: store_user appears in item descriptors: store and user but not using a pattern recognized by the GSA table invalidation mechanism. Cached values from this table will not be updated when user's properties are modified. These properties for this table are: [storeUsers]
12:57:33,241 WARN [StoreRepository] Missing a src id property in item-descriptor user's table named store_user whose column-names are store_id
12:57:33,242 WARN [StoreRepository] Missing a dst id property in item-descriptor store's table named store_user whose column-names are user_id
12:57:33,242 WARN [StoreRepository] Missing a dst multi property in item-descriptor store's table named store_user whose column-name is store_id
12:57:33,242 WARN [StoreRepository] Warning - table: store_user appears in item descriptors: user and store but not using a pattern recognized by the GSA table invalidation mechanism. Cached values from this table will not be updated when store's properties are modified. These properties for this table are: [userStores]
12:57:33,243 WARN [StoreRepository] Missing a src id property in item-descriptor store's table named store_user whose column-names are user_id
12:57:33,243 WARN [StoreRepository] Missing a dst id property in item-descriptor user's table named store_user whose column-names are store_id
12:57:33,243 WARN [StoreRepository] Missing a dst multi property in item-descriptor user's table named store_user whose column-name is user_id
Here's repository definition file:
<item-descriptor name="user" id-space-name="user" display-name="User" display-property="name">
<table name="user_tbl" type="primary" id-column-name="user_id">
<property name="id" column-name="user_id" data-type="string" display-name="Id">
<attribute name="uiwritable" value="false" />
<attribute name="propertySortPriority" value="-1" />
</property>
<property name="name" column-name="user_name" data-type="string" display-name="Name">
<attribute name="propertySortPriority" value="-1" />
</property>
</table>
<table name="store_user" type="multi" id-column-names="user_id" multi-column-name="store_id">
<property name="userStores" display-name="User Stores" data-type="map" column-names="email" component-data-type="string">
<attribute name="propertySortPriority" value="-1" />
<attribute name="uiwritable" value="false" />
</property>
</table>
</item-descriptor>
<item-descriptor name="store" id-space-name="store" display-name="Store" display-property="name">
<table name="store_tbl" type="primary" id-column-name="store_id">
<property name="id" column-name="store_id" data-type="string" display-name="Id">
<attribute name="uiwritable" value="false" />
<attribute name="propertySortPriority" value="-1" />
</property>
<property name="name" column-name="store_name" data-type="string" display-name="Name">
<attribute name="propertySortPriority" value="-1" />
</property>
</table>
<table name="store_user" type="multi" id-column-names="store_id" multi-column-name="user_id">
<property name="userStores" display-name="User Stores" data-type="map" column-names="email" component-data-type="string">
<attribute name="propertySortPriority" value="-1" />
<attribute name="uiwritable" value="false" />
</property>
</table>
</item-descriptor>
I'll appreciate it, if someone tell me what's wrong with my definition.
Thank you in advance,
Jurii.Hi Jurii,
You are right about ATG docs do not have info about M-M that can fit into your requirement. So we have to give it a try :-)
Please try with the below definition to see it it works.
user_tbl and store_tbl - no changes
store_user table has three columns - user_id, store_id and email
<item-descriptor name="user" id-space-name="user" display-name="User" display-property="name">
<table name="user_tbl" type="primary" id-column-name="user_id">
<property name="id" column-name="user_id" data-type="string" display-name="Id">
<attribute name="uiwritable" value="false" />
<attribute name="propertySortPriority" value="-1" />
</property>
<property name="name" column-name="user_name" data-type="string" display-name="Name">
<attribute name="propertySortPriority" value="-1" />
</property>
</table>
<table name="store_user" type="multi" id-column-names="user_id">
<property name="store" display-name="Stores" data-type="set" column-names="store_id" component-item-type="store"/>
<property name="email" display-name="User Store Email" data-type="set" column-names="email" component-data-type="string"/>
</table>
</item-descriptor>
<item-descriptor name="store" id-space-name="store" display-name="Store" display-property="name">
<table name="store_tbl" type="primary" id-column-name="store_id">
<property name="id" column-name="store_id" data-type="string" display-name="Id">
<attribute name="uiwritable" value="false" />
<attribute name="propertySortPriority" value="-1" />
</property>
<property name="name" column-name="store_name" data-type="string" display-name="Name">
<attribute name="propertySortPriority" value="-1" />
</property>
</table>
<table name="store_user" type="multi" id-column-names="store_id">
<property name="user" display-name="Users" data-type="set" column-names="user_id" component-item-type="user"/>
<property name="email" display-name="User Store Email" data-type="set" column-names="email" component-data-type="string"/>
</table>
</item-descriptor>
Thanks,
Gopinath Ramasamy -
Compiler warning: Source folder "server" does not exist and will be ignored
Hi,
i am using NWDS 7.0 SP16. I have a development component type "J2EE Sever Library", which uses a java component. Everything works fine, except during the build i get a warning "Warning: Source folder "server" does not exist and will be ignored.".
Then i created the folder named "server" manually, but the build finished again with warning, now saying:
"Warning: Source folder "server" exists but is empty and will be ignored."
I created a dummy-file in the directory "server" and now the compilation is fine, no warnings.
I like to get my build free of any warnings, so what's wrong here? I found no documentation to create the folder/file manually.
Any help is appreciated.
Regards,
ThomasHi Raman,
I am also getting the same error . i moved my srm transports from DEV to QA and replicated the datasources into BI . and then i moved the BW transports from dev to QA.
when i check the datasource it is pointing to D60 instead of Q60 . when i check the transformations getting the same error :
source system dosen't exist.
can you please let me know how you resolved this issue. your reply will be highly appreciated.
Regards,
Sri -
I'm getting a compiler warning with generics in J2SDK1.5.0
javac -source 1.5 -target 1.5 -Xlint:unchecked Test.java
Test.java:72: warning: unchecked cast to type TYPE mValues = (TYPE[])new Object[aInitialSize];
My code is below, and ideas why this warning appears, is it a bug in my code or is the compiler faulty?
(crosspost warning, I posted the same question on www.javalobby.org, no need for flaming...)
static class Array
private TYPE [] mValues;
public Array(int aInitialSize)
mValues = (TYPE[])new Object[aInitialSize];
public void set(int aIndex, TYPE aValue)
mValues[aIndex] = aValue;
public TYPE get(int aIndex)
return mValues[aIndex];
Sincerely,
Patrik OlssonI asked Sun about this and they replayed:
No, because it is not typesafe. Consider the code
class A<T> {
T[] f() { return (T[])new Object[10]; }
This will cause a class cast exception in its caller, even if the caller has no
cast:
A<Integer> ai = new A<Integer>();
Integer[] a = ai.f(); // BOOM!
Don't use arrays. Use collections.
Maybe you are looking for
-
How do I get my photos and books after installing new Windows?
I installed a new Windows 7 on an SSD to speed up the desktop computer. The new iTunes, of course, was empty. Now I want to sync my iPad with the new iTunes but I'm afraid that I will loose all my books (freely available ones that I downloaded and im
-
Questions in Roll-out projects
Hi Gurus, Please support me. In rollout project 1. Can i use the same types of equipment category , object types, Functional location types, Catalogs , codes, Classes and classification..etc as same as the reference system.?..How? 2. The number rangi
-
When I am in Gmail or most other sites, when I type it automatically goes to the address bar. For example, in Gmail, I will click reply, and the cursor starts flashing in the message box. However, when I start typing, it goes into the address bar ins
-
Help me !(After Effect warning: Unable to create font.)
I'm using Adobe After Effect CS4. It worked pretty well but today, when i lauch it, a message appeared. The message said: "After Effect warning: Unable to create font".Then i searched google and tried many ways: reinstall, restart windows,etc...but i
-
Which Firefox plugins do you use?
Which Firefox plugins do you use? Mine is: Tiny Menu, Adblock Plus Last edited by toorlv (2010-05-09 04:24:06)