< prev index next >

test/jdk/java/lang/ClassLoader/nativeLibrary/NativeLibraryTest.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8164512 8191360
  27  * @requires vm.compMode != "Xcomp"



  28  * @summary verify if the native library is unloaded when the class loader is GC'ed
  29  * @build p.Test
  30  * @run main/othervm/native -Xcheck:jni NativeLibraryTest
  31  */
  32 
  33 import java.io.IOException;
  34 import java.net.MalformedURLException;
  35 import java.net.URL;
  36 import java.net.URLClassLoader;
  37 import java.nio.file.Files;
  38 import java.nio.file.Path;
  39 import java.nio.file.Paths;
  40 
  41 public class NativeLibraryTest {
  42     static final Path CLASSES = Paths.get("classes");
  43     static int unloadedCount = 0;
  44 
  45     /*
  46      * Called by JNI_OnUnload when the native library is unloaded
  47      */




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8164512 8191360
  27  * @requires vm.compMode != "Xcomp"
  28  * @comment Under musl, dlclose is a no-op. The static variable 'count' in libnative.c
  29  * keeps its value across a GC and the check in Test.java fails.
  30  * @requires !vm.musl
  31  * @summary verify if the native library is unloaded when the class loader is GC'ed
  32  * @build p.Test
  33  * @run main/othervm/native -Xcheck:jni NativeLibraryTest
  34  */
  35 
  36 import java.io.IOException;
  37 import java.net.MalformedURLException;
  38 import java.net.URL;
  39 import java.net.URLClassLoader;
  40 import java.nio.file.Files;
  41 import java.nio.file.Path;
  42 import java.nio.file.Paths;
  43 
  44 public class NativeLibraryTest {
  45     static final Path CLASSES = Paths.get("classes");
  46     static int unloadedCount = 0;
  47 
  48     /*
  49      * Called by JNI_OnUnload when the native library is unloaded
  50      */


< prev index next >