Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First call CommPortIdentifier.getPortIdentifiers() ,This can lead to repeated calls #222

Open
you227 opened this issue Apr 22, 2022 · 0 comments

Comments

@you227
Copy link

you227 commented Apr 22, 2022

First call CommPortIdentifier.getPortIdentifiers() ,This can lead to repeated calls,because CommPortIdentifier.java static block It will also be called once CommPortIdentifier.getPortIdentifiers().
I think the this.testNativeCode(); in the NativeResource.java inJarLoad(String name) method should be deleted.

image
image
image

CommPortIdentifier.java

static {
        try {
            CommDriver RXTXDriver = (CommDriver)Class.forName("gnu.io.RXTXCommDriver").newInstance();
            RXTXDriver.initialize();
        } catch (Throwable var1) {
            System.err.println(var1 + " thrown while loading gnu.io.RXTXCommDriver");
        }

        String OS = System.getProperty("os.name");
        if (OS.toLowerCase().indexOf("linux") == -1) {
        }

        SerialManager.getInstance();
    }

.....
NativeResource.java

private void inJarLoad(String name) throws UnsatisfiedLinkError, NativeResourceException {
        InputStream resourceSource = this.locateResource(name);
        File resourceLocation = this.prepResourceLocation(name);

        try {
            this.copyResource(resourceSource, resourceLocation);
        } catch (IOException var5) {
            throw new UnsatisfiedLinkError();
        }

        this.loadResource(resourceLocation);
        this.testNativeCode();
    }

private void testNativeCode() throws UnsatisfiedLinkError {
        CommPortIdentifier.getPortIdentifiers();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant