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

前端 未结 7 1917
悲哀的现实
悲哀的现实 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:00

    I acknowledge that this answer is a late harvest, and you will have solved your problem. But I got stuck in the same problem as you, and researching I found this solution.

    Why happens?

    https://www.oracle.com/java/technologies/faq-sun-packages.html

    Is this behavior wrong?

    No, its a warning telling us that ChachedRowSetImpl does not belong to the public interface, therefore compatibility is not guaranteed.

    Workaround

    The following code snippet creates a CachedRowSet object by using a RowSetFactory which is created by the RowSetProvider:

    RowSetFactory factory = RowSetProvider.newFactory();
    CachedRowSet rowset = factory.createCachedRowSet();
    

    This creates a CachedRowSet object from the implementation class com.sun.rowset.CachedRowSetImpl. It’s equivalent to the following statement:

    CachedRowSet rowset = new com.sun.rowset.CachedRowSetImpl();
    

    However, it’s recommended to create a CachedRowSet object from a RowSetFactory because the reference implementation may be changed in future

提交回复
热议问题