Suppress javac warning “…is internal proprietary API and may be removed in a future release”

前端 未结 7 1905
悲哀的现实
悲哀的现实 2020-11-30 08:09

When I compile the Spring JDBC source on OS X with JDK 1.7.0, I get this warning:

warning: CachedRowSetImpl is internal proprietary API and may be removed in         


        
相关标签:
7条回答
  • 2020-11-30 09:11

    I tried

    @SuppressWarnings("all")
    

    but that didn't work.

    So I resorted to a horrible, horrible kludge which I don't recommend in general, but in this specific case made the warning go away. I used reflection to instantiate a new instance of the com.sun.rowset.CachedRowSetImpl class.

    I replaced this line, which caused the warning:

        return new CachedRowSetImpl();
    

    with this block:

        try {
            final Class<?> aClass = Class.forName("com.sun.rowset.CachedRowSetImpl");
            return (CachedRowSet) aClass.newInstance();
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    

    Please don't do this in your own code without first considering any other option.

    0 讨论(0)
提交回复
热议问题