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

Found and fixed duplicate method definitions for the same API #483

Merged
merged 1 commit into from
Aug 10, 2015

Conversation

lgoldstein
Copy link
Contributor

  • Added duplicate method detection tests for Kernel32, Advapi32 and User32 as they contain most of the low-level API(s) (welcome to add more...) - this is how the issues were discovered and fixed

Kernel32:

  • Removed duplicate GetDiskFreeSpaceEx - preserved the one with LARGE_INTEGER definition as it matches the API definition
  • Added GetDiskFreeSpace API
  • Removed duplicate ReadFile - left and modified the remaining one to use byte[] argument in order to match the WriteFile definition
  • Removed duplicate FormatMessage - kept the one with PointerByReference since it is the definition that closest matches the API (+ it is the only one used in the current code)

User32:

  • Removed duplicate SetWindowLong - kept the one with the int(s) as it matches the API definition
  • Removed duplicate CallNextHookEx - kept the one with LPARAM as it matches the API definition

Please note that the "changes" seem more than that but this is misleading - my IDE (Eclipse) is set up so that on "Save" it trims trailing white spaces in the source lines, replaces TAB(s) with 4 spaces, removes unused imports and adds missing @OverRide(s). I think this is recommended behavior, but do let me know if you disagree and I will configure it otherwise.

@dblock
Copy link
Member

dblock commented Aug 6, 2015

There's a compile error in a contrib directory that looks legit:

compile:
    [mkdir] Created dir: /Users/travis/build/twall/jna/contrib/w32keyhook/build/classes
    [javac] Compiling 1 source file to /Users/travis/build/twall/jna/contrib/w32keyhook/build/classes
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
    [javac] /Users/travis/build/twall/jna/contrib/w32keyhook/com/sun/jna/contrib/demo/KeyHook.java:50: error: method CallNextHookEx in interface User32 cannot be applied to given types;
    [javac]                 return lib.CallNextHookEx(hhk, nCode, wParam, info.getPointer());
    [javac]                           ^
    [javac]   required: HHOOK,int,WPARAM,LPARAM
    [javac]   found: HHOOK,int,WPARAM,Pointer
    [javac]   reason: actual argument Pointer cannot be converted to LPARAM by method invocation conversion
    [javac] 1 error
    [javac] 1 warning

@lgoldstein
Copy link
Contributor Author

Sorry I missed it - fixed and re-pushed the commit

@lgoldstein
Copy link
Contributor Author

Took the opportunity to also remove the GetIconInfo overload with the HANDLE.

@dblock
Copy link
Member

dblock commented Aug 9, 2015

Check out Travis-CI, didn't dig into the issues, but I am pretty sure this should be passing here.

@lgoldstein
Copy link
Contributor Author

You are right - I can't explain how, but seems like a bunch of critical import(s) was removed from the file. I restored them and now everything should compile - I don't know how this has happened since I compiled and tested my code before committing...

@lgoldstein
Copy link
Contributor Author

All checks have passed successfully now

@dblock
Copy link
Member

dblock commented Aug 10, 2015

Thanks, merging. Good work.

dblock added a commit that referenced this pull request Aug 10, 2015
Found and fixed duplicate method definitions for the same API
@dblock dblock merged commit ec988a2 into java-native-access:master Aug 10, 2015
@lgoldstein lgoldstein deleted the duplicate-methods branch August 10, 2015 13:17
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

Successfully merging this pull request may close these issues.

None yet

2 participants