• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with unchecked call  RSS feed

 
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somone show me how to get rid of this compile warning please?

C:\Java Dev\Play\reflection>Javac -Xlint ReflectionPlay.java
ReflectionPlay.java:99: warning: [unchecked] unchecked call to getConstructor(ja
va.lang.Class<?>...) as a member of the raw type java.lang.Class
Constructor constructor = aClass.getConstructor(new Class[]{String.c
lass});
^
1 warning
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can add @SuppressWarnings("unchecked").
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or make sure that you don't use raw types: so instead of Class, use Class<Something> (where "Something" is the type argument; the name of the class that you are getting the Class object for).
 
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both Constructor and Class have generic types. You'll need to supply these, using the unbound wildcard if not known.

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!