Skip to content

Commit

Permalink
Apply generic definitions wherever applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyor Goldstein committed Jan 12, 2016
1 parent 3e67635 commit 0466f33
Show file tree
Hide file tree
Showing 75 changed files with 2,003 additions and 1,857 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Features
* [#567](https://github.com/java-native-access/jna/pull/567): Added `PrintWindow`, `IsWindowEnabled`, `IsWindow`, `FindWindowEx`, `GetAncestor`, `GetCursorPos`, `SetCursorPos`, `SetWinEventHook`, `UnhookWinEvent`, `CopyIcon`, and `GetClassLong` to `com.sun.jna.platform.win32.User32` and supporting constants to `com.sun.jna.platform.win32.WinUser` - [@mlfreeman2](https://github.com/mlfreeman2).
* [#573](https://github.com/java-native-access/jna/pull/573): Added `EnumProcessModules`, `GetModuleInformation`, and `GetProcessImageFileName` to `com.sun.jna.platform.win32.Psapi` and added `ExtractIconEx` to `com.sun.jna.platform.win32.Shell32` - [@mlfreeman2](https://github.com/mlfreeman2).
* [#574](https://github.com/java-native-access/jna/pull/574): Using static final un-modifiable List of field names for structure(s) [@lgoldstein](https://github.com/lgoldstein)
* [#577](https://github.com/java-native-access/jna/pull/577): Apply generic definitions wherever applicable [@lgoldstein](https://github.com/lgoldstein)

Bug Fixes
---------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ public void testMSWord() {
MSWord msWord = null;

// http://msdn.microsoft.com/en-us/library/office/ff839952(v=office.15).aspx
LONG wdFormatPDF = new LONG(17); // PDF format.
LONG wdFormatRTF = new LONG(6); // Rich text format (RTF).
LONG wdFormatHTML = new LONG(8); // Standard HTML format.
LONG wdFormatDocument = new LONG(0); // Microsoft Office Word 97 - 2003 binary file format.
LONG wdFormatDocumentDefault = new LONG(16); // Word default document file format. For Word 2010, this is the DOCX format.
LONG wdFormatPDF = Long.valueOf(17); // PDF format.
LONG wdFormatRTF = Long.valueOf(6); // Rich text format (RTF).
LONG wdFormatHTML = Long.valueOf(8); // Standard HTML format.
LONG wdFormatDocument = Long.valueOf(0); // Microsoft Office Word 97 - 2003 binary file format.
LONG wdFormatDocumentDefault = Long.valueOf(16); // Word default document file format. For Word 2010, this is the DOCX format.

// http://msdn.microsoft.com/en-us/library/office/ff838709(v=office.15).aspx
LONG wdOriginalDocumentFormat = new LONG(1); // Original document format.
LONG wdPromptUser = new LONG(2); // Prompt user to select a document format.
LONG wdWordDocument = new LONG(0); // Microsoft Word document format.
LONG wdOriginalDocumentFormat = Long.valueOf(1); // Original document format.
LONG wdPromptUser = Long.valueOf(2); // Prompt user to select a document format.
LONG wdWordDocument = Long.valueOf(0); // Microsoft Word document format.

try {
msWord = new MSWord();
Expand Down
2 changes: 1 addition & 1 deletion contrib/platform/src/com/sun/jna/platform/FileMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void addWatch(File dir, int mask) throws IOException {
}

public void addWatch(File dir, int mask, boolean recursive) throws IOException {
watched.put(dir, new Integer(mask));
watched.put(dir, Integer.valueOf(mask));
watch(dir, mask, recursive);
}

Expand Down
8 changes: 4 additions & 4 deletions contrib/platform/src/com/sun/jna/platform/WindowUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ private boolean usingUpdateLayeredWindow(Window w) {
private void storeAlpha(Window w, byte alpha) {
if (w instanceof RootPaneContainer) {
JRootPane root = ((RootPaneContainer)w).getRootPane();
Byte b = alpha == (byte)0xFF ? null : new Byte(alpha);
Byte b = alpha == (byte)0xFF ? null : Byte.valueOf(alpha);
root.putClientProperty(TRANSPARENT_ALPHA, b);
}
}
Expand Down Expand Up @@ -1010,7 +1010,7 @@ else if (type == PathIterator.SEG_LINETO) {
points.add(new POINT((int)coords[0], (int)coords[1]));
}
else if (type == PathIterator.SEG_CLOSE) {
sizes.add(new Integer(size));
sizes.add(Integer.valueOf(size));
}
else {
throw new RuntimeException("Area is not polygonal: " + area);
Expand Down Expand Up @@ -1338,7 +1338,7 @@ private void fixWindowDragging(Window w, String context) {
public void setWindowAlpha(final Window w, final float alpha) {
if (w instanceof RootPaneContainer) {
JRootPane p = ((RootPaneContainer)w).getRootPane();
p.putClientProperty("Window.alpha", new Float(alpha));
p.putClientProperty("Window.alpha", Float.valueOf(alpha));
fixWindowDragging(w, "setWindowAlpha");
}
whenDisplayable(w, new Runnable() {
Expand All @@ -1348,7 +1348,7 @@ public void run() {
peer.getClass().getMethod("setAlpha", new Class[]{
float.class
}).invoke(peer, new Object[]{
new Float(alpha)
Float.valueOf(alpha)
});
}
catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
import java.util.Map.Entry;
import java.util.TreeMap;

import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinBase.FE_EXPORT_FUNC;
import com.sun.jna.platform.win32.WinBase.FE_IMPORT_FUNC;
import com.sun.jna.platform.win32.WinBase.FILETIME;
Expand All @@ -72,9 +69,6 @@
import com.sun.jna.platform.win32.WinNT.SID_NAME_USE;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;


/**
Expand Down Expand Up @@ -975,9 +969,9 @@ public static Object registryGetValue(HKEY hkKey, String subKey,
byteData.write(0, lpData, 0, lpcbData.getValue());

if (lpType.getValue() == WinNT.REG_DWORD) {
result = new Integer(byteData.getInt(0));
result = Integer.valueOf(byteData.getInt(0));
} else if (lpType.getValue() == WinNT.REG_QWORD) {
result = new Long(byteData.getLong(0));
result = Long.valueOf(byteData.getLong(0));
} else if (lpType.getValue() == WinNT.REG_BINARY) {
result = byteData.getByteArray(0, lpcbData.getValue());
} else if ((lpType.getValue() == WinNT.REG_SZ)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public TlbCmdlineArgs(String[] args) {

public int getIntParam(String key) {
String param = this.getRequiredParam(key);
return new Integer(param).intValue();
return Integer.parseInt(param);
}

public String getParam(String key) {
Expand Down
2 changes: 1 addition & 1 deletion contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public SAFEARRAYBOUND(Pointer pointer) {

public SAFEARRAYBOUND(int cElements, int lLbound) {
this.cElements = new ULONG(cElements);
this.lLbound = new LONG(lLbound);
this.lLbound = Long.valueOf(lLbound);
this.write();
}

Expand Down
6 changes: 3 additions & 3 deletions contrib/platform/src/com/sun/jna/platform/win32/Variant.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public VARIANT(DATE value) {
}

public VARIANT(byte value) {
this(new BYTE(value));
this(Byte.valueOf(value));
}

public VARIANT(BYTE value) {
Expand All @@ -211,12 +211,12 @@ public VARIANT(CHAR value) {

public VARIANT(short value) {
this();
this.setValue(VT_I2, new SHORT(value));
this.setValue(VT_I2, Short.valueOf(value));
}

public VARIANT(int value) {
this();
this.setValue(VT_I4, new LONG(value));
this.setValue(VT_I4, Long.valueOf(value));
}

public VARIANT(long value) {
Expand Down
4 changes: 2 additions & 2 deletions contrib/platform/src/com/sun/jna/platform/win32/WinDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public class LONGByReference extends ByReference {
* Instantiates a new LONG by reference.
*/
public LONGByReference() {
this(new LONG(0));
this(Long.valueOf(0));
}

/**
Expand Down Expand Up @@ -265,7 +265,7 @@ public void setValue(LONG value) {
* @return the value
*/
public LONG getValue() {
return new LONG(getPointer().getInt(0));
return Long.valueOf(getPointer().getInt(0));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public ShellWindows(IDispatch iDispatch)
public InternetExplorer Item(int idx)
{
VARIANT arg = new VARIANT();
arg.setValue(Variant.VT_I4, new LONG(idx));
arg.setValue(Variant.VT_I4, Long.valueOf(idx));
IDispatch result = (IDispatch) invoke("Item", arg).getValue();
if (result == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void testSafeArrayPutGetElement() throws Exception {
SAFEARRAY varArray = OleAutoUtil.createVarArray(10);

for (int i = 0; i < 10; i++) {
VARIANT variant = new VARIANT(new SHORT(i + i*100));
VARIANT variant = new VARIANT(Short.valueOf(i + i*100));
//System.out.println(variant.toString(true));
OleAutoUtil.SafeArrayPutElement(varArray, i, variant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public VariantTest() {
}

public void testVariantClear() {
VARIANT variant = new VARIANT(new SHORT(33333));
VARIANT variant = new VARIANT(Short.valueOf(33333));
HRESULT hr = OleAuto.INSTANCE.VariantClear(variant.getPointer());

assertTrue("hr: " + hr.intValue(), hr.intValue() == 0);
}

public void testVariantCopyShort() {
VARIANT variantSource = new VARIANT(new SHORT(33333));
VARIANT variantSource = new VARIANT(Short.valueOf(33333));
VARIANT variantDest = new VARIANT();

//System.out.println(variantSource.toString(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void setUp() throws Exception {
events = new HashMap<Integer, FileEvent>();
final FileListener listener = new FileListener() {
public void fileChanged(FileEvent e) {
events.put(new Integer(e.getType()), e);
events.put(Integer.valueOf(e.getType()), e);
}
};
monitor = FileMonitor.getInstance();
Expand Down Expand Up @@ -190,7 +190,7 @@ private void assertFileEventCreated(final File expectedFile)
private FileEvent waitForFileEvent(final int expectedFileEvent)
throws InterruptedException {

final Integer expectedFileEventInteger = new Integer(expectedFileEvent);
final Integer expectedFileEventInteger = Integer.valueOf(expectedFileEvent);

FileEvent actualEvent = (FileEvent)events.get(expectedFileEventInteger);
final long start = System.currentTimeMillis();
Expand Down
2 changes: 1 addition & 1 deletion contrib/x11/src/jnacontrib/x11/api/X.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public void fromXModifierKeymap(X11.XModifierKeymapRef xModifierKeymapRef) {
for (int keyNr = 0; keyNr < count; keyNr++) {
byte key = keys[modNr*count + keyNr];
if (key != 0) {
modifier.add(new Byte(key));
modifier.add(Byte.valueOf(key));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/x11/src/jnacontrib/x11/demos/XDesktopDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private void refreshDesktopsAndWindows() throws X.X11Exception {
X.Window window = windows[i];
X.Window.Geometry geo = window.getGeometry();
int windowId = window.getID();
data[i][0] = String.format("0x%08X", new Object[]{new Integer(windowId)});
data[i][0] = String.format("0x%08X", new Object[]{Integer.valueOf(windowId)});
data[i][1] = "" + window.getDesktop();
data[i][2] = window.getTitle();
data[i][3] = "" + geo.x;
Expand Down
8 changes: 4 additions & 4 deletions src/com/sun/jna/CallbackParameterContext.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* Lesser General Public License for more details.
*/
package com.sun.jna;

Expand All @@ -19,7 +19,7 @@ public class CallbackParameterContext extends FromNativeContext {
private Method method;
private Object[] args;
private int index;
CallbackParameterContext(Class javaType, Method m, Object[] args, int index) {
CallbackParameterContext(Class<?> javaType, Method m, Object[] args, int index) {
super(javaType);
this.method = m;
this.args = args;
Expand Down
8 changes: 4 additions & 4 deletions src/com/sun/jna/CallbackProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* Lesser General Public License for more details.
*/
package com.sun.jna;

Expand All @@ -19,12 +19,12 @@
*/
public interface CallbackProxy extends Callback {

/** This is the callback method invoked from native code.
/** This is the callback method invoked from native code.
* It must <em>not</em> throw any exceptions whatsoever.
*/
Object callback(Object[] args);
/** Returns the types of the parameters to the callback method. */
Class[] getParameterTypes();
Class<?>[] getParameterTypes();
/** Returns the type of the callback method's return value. */
Class getReturnType();
Class<?> getReturnType();
}
Loading

0 comments on commit 0466f33

Please sign in to comment.