From 9c0c4f6fc6139ca652fa3f8702d605a29340020b Mon Sep 17 00:00:00 2001 From: kairoh <3878594+kairoh@users.noreply.github.com> Date: Sat, 7 Oct 2023 19:50:40 +0000 Subject: [PATCH] Sonar --- .../driver/usb/LibUsbDetectionHelper.java | 2 - .../quarkus/awt/deployment/AwtProcessor.java | 42 +++++++------------ 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/driver/src/main/java/studio/driver/usb/LibUsbDetectionHelper.java b/driver/src/main/java/studio/driver/usb/LibUsbDetectionHelper.java index 463bd256c..afded6fad 100644 --- a/driver/src/main/java/studio/driver/usb/LibUsbDetectionHelper.java +++ b/driver/src/main/java/studio/driver/usb/LibUsbDetectionHelper.java @@ -111,8 +111,6 @@ private void registerHook(LibUsbAsyncEventsWorker asyncEvtWorker) { LOGGER.info("Stopping async event handling worker thread"); asyncEvtWorker.abort(); } - LOGGER.info("Exiting libusb..."); - // TODO: LibUsb.exit(context); })); } diff --git a/quarkus-usb4java/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java b/quarkus-usb4java/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java index 6851aa6ee..052767dcb 100644 --- a/quarkus-usb4java/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java +++ b/quarkus-usb4java/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java @@ -98,7 +98,8 @@ ReflectiveClassBuildItem setupReflectionClassesWithMethods() { // k: test "javax.imageio.ImageIO", "javax.imageio.stream.FileImageInputStream", - "javax.imageio.stream.FileImageOututStream" + "javax.imageio.stream.FileImageOututStream", + "javax.imageio.ImageIO$ImageWriterIterator" // k: end ).methods().build(); } @@ -112,37 +113,23 @@ void setupAWTInit(BuildProducer jc, // Dynamically loading shared objects instead // of baking in static libs: https://github.com/oracle/graal/issues/4921 if (v.compareTo(GraalVM.Version.VERSION_23_0_0) >= 0) { - jm.produce(new JniRuntimeAccessMethodBuildItem("java.lang.System", "load", "java.lang.String")); - jm.produce(new JniRuntimeAccessMethodBuildItem("java.lang.System", "setProperty", "java.lang.String", "java.lang.String")); - jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLock")); - jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLockNotify")); - jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLockNotifyAll")); - jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLockWait", "long")); - jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtUnlock")); - jf.produce(new JniRuntimeAccessFieldBuildItem("sun.awt.SunToolkit", "AWT_LOCK")); - jf.produce(new JniRuntimeAccessFieldBuildItem("sun.awt.SunToolkit", "AWT_LOCK_COND")); + String string = "java.lang.String"; + String sunToolkit = "sun.awt.SunToolkit"; + jm.produce(new JniRuntimeAccessMethodBuildItem("java.lang.System", "load", string)); + jm.produce(new JniRuntimeAccessMethodBuildItem("java.lang.System", "setProperty", string, string)); + jm.produce(new JniRuntimeAccessMethodBuildItem(sunToolkit, "awtLock")); + jm.produce(new JniRuntimeAccessMethodBuildItem(sunToolkit, "awtLockNotify")); + jm.produce(new JniRuntimeAccessMethodBuildItem(sunToolkit, "awtLockNotifyAll")); + jm.produce(new JniRuntimeAccessMethodBuildItem(sunToolkit, "awtLockWait", "long")); + jm.produce(new JniRuntimeAccessMethodBuildItem(sunToolkit, "awtUnlock")); + jf.produce(new JniRuntimeAccessFieldBuildItem(sunToolkit, "AWT_LOCK")); + jf.produce(new JniRuntimeAccessFieldBuildItem(sunToolkit, "AWT_LOCK_COND")); jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.X11.XErrorHandlerUtil", "init", "long")); jc.produce(new JniRuntimeAccessBuildItem(false, false, true, "sun.awt.X11.XToolkit")); jm.produce(new JniRuntimeAccessMethodBuildItem("java.lang.Thread", "yield")); } } - /* - @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) - JniRuntimeAccessBuildItem setupJava2DClasses() { - return new JniRuntimeAccessBuildItem(true, true, tru - // Java 20 :test - "javax.imageio.spi.ImageReaderSpi", - "javax.imageio.spi.ImageWriterSpi", - "com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi", - "com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi", - "com.sun.imageio.spi.RAFImageInputStreamSpi", - "com.sun.imageio.spi.FileImageOutputStreamSpi" - // - ); - } - */ - @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) JniRuntimeAccessBuildItem setupJava2DClasses(NativeImageRunnerBuildItem nativeImageRunnerBuildItem) { final GraalVM.Version v = nativeImageRunnerBuildItem.getBuildRunner().getGraalVMVersion(); @@ -284,7 +271,8 @@ JniRuntimeAccessBuildItem setupJava2DClasses(NativeImageRunnerBuildItem nativeIm if (v.jdkVersionGreaterOrEqualTo(19, 0)) { classes.add("sun.font.FontUtilities"); // k: test - //classes.add("javax.imageio.ImageIO"); + classes.add("javax.imageio.ImageIO"); + classes.add("javax.imageio.ImageIO$ImageWriterIterator"); //classes.add("javax.imageio.stream.FileImageInputStream"); //classes.add("javax.imageio.stream.FileImageOutputStream"); // k: end