• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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: 22850
132
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: 22850
132
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic