Skip to content

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

Merged
dblock merged 1 commit intojava-native-access:masterfrom
lgoldstein:duplicate-methods
Aug 10, 2015
Merged

Found and fixed duplicate method definitions for the same API#483
dblock merged 1 commit intojava-native-access:masterfrom
lgoldstein:duplicate-methods

Conversation

@lgoldstein
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@lgoldstein
Copy link
Copy Markdown
Contributor Author

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

@dblock
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

All checks have passed successfully now

@dblock
Copy link
Copy Markdown
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
mstyura pushed a commit to mstyura/jna that referenced this pull request Sep 9, 2024
…#483)

Motivation:

We did set the incorrect property which did result in an incorrect Automatic-Module-Name

Modifications:

Set the correct property.

Result:

Generate correct module names
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.

2 participants