Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error: warnings found and -Werror specified in Junit

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I need to access a private method String getFoo(X509Certificate cert) of A.java in junit testing in my project ,I have written the code like this –


I am getting an error when running ant test

C:\Ajava:22: warning: [rawtypes] found raw type: Class
   [javac]             Class[] paramVal = new Class[1];
   [javac]             ^
   [javac]   missing type arguments for generic class Class<T>
   [javac]   where T is a type-variable:
   [javac]     T extends Object declared in class Class
   [javac] C:\A.java:22: warning: [rawtypes] found raw type: Class
   [javac]             Class[] paramVal= new Class[1];
   [javac]                                     ^
   [javac]   missing type arguments for generic class Class<T>
   [javac]   where T is a type-variable:
   [javac]     T extends Object declared in class Class
   [javac] error: warnings found and -Werror specified
   [javac] 1 error
   [javac] 2 warnings

What will be the solution for this?
Thanks
 
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Class is a generic type. That means you should give it a generic type between <>, or a wildcard if you don't know what the actual type is. For instance:


That can be made shorter by using an array initializer:

Or, because Class.getDeclaredMethod's last parameter is a varargs parameter, you can skip the array completely:
 
Abhra Kar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Rob for the explanation.
 
Rob Spoor
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
Crusading Chameleon likes the size of this ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic