suppress generics warnings

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

suppress generics warnings

rvjansen
Since Java 5 introduced generics the java compiler issues some warnings for the use of Collection classes that are not restricted by a Type.

They look like:

Note: EssoNews.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
The odd thing is that one cannot suppress these warnings with the -nowarn option on javac.

For NetRexx, we have no way to specify types on a collection class. There is, however, a way to get rid of these messages, by using the @annotations feature we introduced some releases ago.

class EssoNews

  properties static
  zipFile = 'BNA-DIG-ESSONEWS-1984_images.zip'
  /**
   * Default constructor
   */
  method EssoNews()
    return
    
    @SuppressWarnings("unchecked")
  method main(args=String[]) static
    say Date() "EssoNews Started"
    issueMap = TreeMap()
    say Date() "EssoNews Reading" zipFile
    a     = Zip().readZip(zipFile)
    i     = a.iterator()
    loop while i.hasNext()
      filename_ = i.next()
      parse filename_ 'ESSONEWS-' issue '-‘ .
(…) etc

This ensures the messages will stay away. The suppression can be done with a method scope.
I could generate this annotation for every method into the java source. What are the thoughts on this?

best regards,

René.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: suppress generics warnings

Mike Cowlishaw
It's probably what I would have done ... :-)


From: [hidden email] [mailto:[hidden email]] On Behalf Of René Jansen
Sent: 11 April 2019 18:02
To: IBM Netrexx
Subject: [Ibm-netrexx] suppress generics warnings

Since Java 5 introduced generics the java compiler issues some warnings for the use of Collection classes that are not restricted by a Type.

They look like:

Note: EssoNews.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
The odd thing is that one cannot suppress these warnings with the -nowarn option on javac.

For NetRexx, we have no way to specify types on a collection class. There is, however, a way to get rid of these messages, by using the @annotations feature we introduced some releases ago.

class EssoNews

  properties static
  zipFile = 'BNA-DIG-ESSONEWS-1984_images.zip'
  /**
   * Default constructor
   */
  method EssoNews()
    return
    
    @SuppressWarnings("unchecked")
  method main(args=String[]) static
    say Date() "EssoNews Started"
    issueMap = TreeMap()
    say Date() "EssoNews Reading" zipFile
    a     = Zip().readZip(zipFile)
    i     = a.iterator()
    loop while i.hasNext()
      filename_ = i.next()
      parse filename_ 'ESSONEWS-' issue '-‘ .
(…) etc

This ensures the messages will stay away. The suppression can be done with a method scope.
I could generate this annotation for every method into the java source. What are the thoughts on this?

best regards,

René.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/