Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8278264

Trying to compile basic OpenCV example crashes JVM

XMLWordPrintable

    • x86_64
    • linux

      ADDITIONAL SYSTEM INFORMATION :
      $ java --version
      openjdk 11.0.12 2021-07-20
      OpenJDK Runtime Environment (build 11.0.12+7-Ubuntu-0ubuntu3)
      OpenJDK 64-Bit Server VM (build 11.0.12+7-Ubuntu-0ubuntu3, mixed mode, sharing)

      $ cat /etc/lsb-release
      DISTRIB_ID=LinuxMint
      DISTRIB_RELEASE=20.2
      DISTRIB_CODENAME=uma
      DISTRIB_DESCRIPTION="Linux Mint 20.2 Uma"


      A DESCRIPTION OF THE PROBLEM :
      Trying to compile basic OpenCV 4.5.3 example Java code crashes the JVM

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Installed OpenCV 4.5 & Java bindings on my debian based distro
      libopencv-calib3d-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-calib3d4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-contrib-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-contrib4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-core-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed]
      libopencv-core4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed]
      libopencv-dnn-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-dnn4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-features2d-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-features2d4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-flann-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-flann4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-highgui-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-highgui4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-imgcodecs-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-imgcodecs4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-imgproc-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-imgproc4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-ml-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-ml4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-objdetect-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-objdetect4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-photo-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-photo4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-shape-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-shape4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-stitching-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-stitching4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-superres-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-superres4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-video-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-video4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-videoio-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-videoio4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-videostab-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-videostab4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-viz-dev/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv-viz4.5/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      libopencv4.5-java/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed]
      libopencv4.5-jni/impish,now 4.5.3+dfsg-1ubuntu1 amd64 [installed,automatic]
      opencv-data/impish,impish,now 4.5.3+dfsg-1ubuntu1 all [installed]
      opencv-doc/impish,impish,now 4.5.3+dfsg-1ubuntu1 all [installed]


      2. Copied basic example from:
      https://www.tutorialspoint.com/javaexamples/copy_and_paste_image.htm

      3. Tried to compile it
      CVCP=/usr/share/java/opencv4/opencv-453.jar
      PrjCP=./sample/src/main/java/
      javac -cp $CVCP:$PrjCP $PrjCP/org/openjfx/CopyAndPasteAnImage.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should compile
      ACTUAL -
      Got an error telling me to create this bug report:
      An exception has occurred in the compiler (11.0.12). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.nio.file.ReadOnlyFileSystemException
      at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.checkWritable(ZipFileSystem.java:170)
      at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.newOutputStream(ZipFileSystem.java:538)
      at jdk.zipfs/jdk.nio.zipfs.ZipPath.newOutputStream(ZipPath.java:859)
      at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newOutputStream(ZipFileSystemProvider.java:282)
      at java.base/java.nio.file.Files.newOutputStream(Files.java:220)
      at jdk.compiler/com.sun.tools.javac.file.PathFileObject.openOutputStream(PathFileObject.java:464)
      at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1739)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:757)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1635)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1603)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
      at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
      at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:

      ---------- BEGIN SOURCE ----------
      import org.opencv.core.Core;
      import org.opencv.core.Mat;
      import org.opencv.imgcodecs.Imgcodecs;

      public class CopyAndPasteAnImage {
         public static void main(String args[]) {

            //Loading the OpenCV core library
            System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
            
            //Reading the Image from the file and storing it in to a Matrix object
            String file = "C:/opencv/logo.jpg";
            
            Mat matrix = Imgcodecs.imread(file);
            System.out.println("Image Loaded ..........");
            String file2 = "C:/opencv/logoResaved.jpg";

            //Writing the image
            Imgcodecs.imwrite(file2, matrix);
            System.out.println("Image Saved ............");
         }
      }
      ---------- END SOURCE ----------

            adev Anupam Dev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: