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

Null pointer exception occurs when a ComException is created #412

Closed
JohnRobPeter opened this issue Mar 18, 2015 · 3 comments
Closed

Null pointer exception occurs when a ComException is created #412

JohnRobPeter opened this issue Mar 18, 2015 · 3 comments
Labels

Comments

@JohnRobPeter
Copy link

COMUtils.java

public static void checkRC(HRESULT hr) {
        checkRC(hr, (EXCEPINFO)null, (IntByReference)null);
    }

    public static void checkRC(HRESULT hr, EXCEPINFO pExcepInfo, IntByReference puArgErr) {
        if(FAILED(hr)) {
            String formatMessageFromHR = Kernel32Util.formatMessage(hr);
            throw new COMException(formatMessageFromHR, pExcepInfo, puArgErr);
        }
    }

while the first method calls the second with the second and third params set to null the second method creates a new ComException instance by passing a message got from Kernel32 and two null received as parameters to the constructor of ComException class.

COMException.java

    public COMException(String message, EXCEPINFO pExcepInfo, IntByReference puArgErr) {
        super(message + " (puArgErr=" + puArgErr.getValue() + ")");
        this.pExcepInfo = pExcepInfo;
        this.puArgErr = puArgErr;
    }

as the ComException class constructor has a call to super with a puArgErr.getValue as param we have a null pointer exception here because puArgErr from the code above is set to null

@JohnRobPeter JohnRobPeter changed the title Null pointer exception occures when a ComException is created Null pointer exception occurs when a ComException is created Mar 18, 2015
@dblock
Copy link
Member

dblock commented Mar 18, 2015

This is a good repro, turn it into a unit test and a fix?

@dblock dblock added the bug label Mar 18, 2015
@dblock
Copy link
Member

dblock commented Apr 6, 2015

Bump.

@matthiasblaesing
Copy link
Member

This was fixed by: d6675fa

mstyura pushed a commit to mstyura/jna that referenced this issue Sep 9, 2024

Motivation:

Since PR java-native-access#406 the Android build was not working anymore

Modifications:

Re-added the ldflags to the Android profile of the native library

Result:

The Android library successfully builds again

This reverts commit 122d099.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants