Skip to content

Commit 0b9c7a3

Browse files
author
Lyor Goldstein
committed
Apply generic definitions wherever applicable
1 parent 3e67635 commit 0b9c7a3

File tree

73 files changed

+2004
-1852
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2004
-1852
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Features
3131
* [#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).
3232
* [#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).
3333
* [#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)
34+
* [#577](https://github.com/java-native-access/jna/pull/577): Apply generic definitions wherever applicable [@lgoldstein](https://github.com/lgoldstein)
3435

3536
Bug Fixes
3637
---------

contrib/msoffice/src/com/sun/jna/platform/win32/COM/office/MSOfficeDemo.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ public void testMSWord() {
2626
MSWord msWord = null;
2727

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

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

4040
try {
4141
msWord = new MSWord();

contrib/platform/src/com/sun/jna/platform/FileMonitor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void addWatch(File dir, int mask) throws IOException {
7979
}
8080

8181
public void addWatch(File dir, int mask, boolean recursive) throws IOException {
82-
watched.put(dir, new Integer(mask));
82+
watched.put(dir, Integer.valueOf(mask));
8383
watch(dir, mask, recursive);
8484
}
8585

contrib/platform/src/com/sun/jna/platform/WindowUtils.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ private boolean usingUpdateLayeredWindow(Window w) {
739739
private void storeAlpha(Window w, byte alpha) {
740740
if (w instanceof RootPaneContainer) {
741741
JRootPane root = ((RootPaneContainer)w).getRootPane();
742-
Byte b = alpha == (byte)0xFF ? null : new Byte(alpha);
742+
Byte b = alpha == (byte)0xFF ? null : Byte.valueOf(alpha);
743743
root.putClientProperty(TRANSPARENT_ALPHA, b);
744744
}
745745
}
@@ -1010,7 +1010,7 @@ else if (type == PathIterator.SEG_LINETO) {
10101010
points.add(new POINT((int)coords[0], (int)coords[1]));
10111011
}
10121012
else if (type == PathIterator.SEG_CLOSE) {
1013-
sizes.add(new Integer(size));
1013+
sizes.add(Integer.valueOf(size));
10141014
}
10151015
else {
10161016
throw new RuntimeException("Area is not polygonal: " + area);
@@ -1338,7 +1338,7 @@ private void fixWindowDragging(Window w, String context) {
13381338
public void setWindowAlpha(final Window w, final float alpha) {
13391339
if (w instanceof RootPaneContainer) {
13401340
JRootPane p = ((RootPaneContainer)w).getRootPane();
1341-
p.putClientProperty("Window.alpha", new Float(alpha));
1341+
p.putClientProperty("Window.alpha", Float.valueOf(alpha));
13421342
fixWindowDragging(w, "setWindowAlpha");
13431343
}
13441344
whenDisplayable(w, new Runnable() {
@@ -1348,7 +1348,7 @@ public void run() {
13481348
peer.getClass().getMethod("setAlpha", new Class[]{
13491349
float.class
13501350
}).invoke(peer, new Object[]{
1351-
new Float(alpha)
1351+
Float.valueOf(alpha)
13521352
});
13531353
}
13541354
catch (Exception e) {

contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ public static String getUserName() {
131131

132132
if (!result) {
133133
switch (Kernel32.INSTANCE.GetLastError()) {
134-
case W32Errors.ERROR_INSUFFICIENT_BUFFER:
135-
buffer = new char[len.getValue()];
136-
break;
134+
case W32Errors.ERROR_INSUFFICIENT_BUFFER:
135+
buffer = new char[len.getValue()];
136+
break;
137137

138-
default:
139-
throw new Win32Exception(Native.getLastError());
138+
default:
139+
throw new Win32Exception(Native.getLastError());
140140
}
141141

142142
result = Advapi32.INSTANCE.GetUserNameW(buffer, len);
@@ -975,9 +975,9 @@ public static Object registryGetValue(HKEY hkKey, String subKey,
975975
byteData.write(0, lpData, 0, lpcbData.getValue());
976976

977977
if (lpType.getValue() == WinNT.REG_DWORD) {
978-
result = new Integer(byteData.getInt(0));
978+
result = Integer.valueOf(byteData.getInt(0));
979979
} else if (lpType.getValue() == WinNT.REG_QWORD) {
980-
result = new Long(byteData.getLong(0));
980+
result = Long.valueOf(byteData.getLong(0));
981981
} else if (lpType.getValue() == WinNT.REG_BINARY) {
982982
result = byteData.getByteArray(0, lpcbData.getValue());
983983
} else if ((lpType.getValue() == WinNT.REG_SZ)

contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbCmdlineArgs.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public TlbCmdlineArgs(String[] args) {
2323

2424
public int getIntParam(String key) {
2525
String param = this.getRequiredParam(key);
26-
return new Integer(param).intValue();
26+
return Integer.parseInt(param);
2727
}
2828

2929
public String getParam(String key) {

contrib/platform/src/com/sun/jna/platform/win32/Variant.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,12 @@ public VARIANT(CHAR value) {
211211

212212
public VARIANT(short value) {
213213
this();
214-
this.setValue(VT_I2, new SHORT(value));
214+
this.setValue(VT_I2, Short.valueOf(value));
215215
}
216216

217217
public VARIANT(int value) {
218218
this();
219-
this.setValue(VT_I4, new LONG(value));
219+
this.setValue(VT_I4, Long.valueOf(value));
220220
}
221221

222222
public VARIANT(long value) {

contrib/platform/src/com/sun/jna/platform/win32/WinDef.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public class LONGByReference extends ByReference {
237237
* Instantiates a new LONG by reference.
238238
*/
239239
public LONGByReference() {
240-
this(new LONG(0));
240+
this(new LONG(0L));
241241
}
242242

243243
/**

contrib/platform/test/com/sun/jna/platform/win32/COM/ShellApplicationWindowsTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public ShellWindows(IDispatch iDispatch)
134134
public InternetExplorer Item(int idx)
135135
{
136136
VARIANT arg = new VARIANT();
137-
arg.setValue(Variant.VT_I4, new LONG(idx));
137+
arg.setValue(Variant.VT_I4, Long.valueOf(idx));
138138
IDispatch result = (IDispatch) invoke("Item", arg).getValue();
139139
if (result == null)
140140
{

contrib/platform/test/com/sun/jna/platform/win32/OleAutoUtilTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
*/
1313
package com.sun.jna.platform.win32;
1414

15-
import junit.framework.TestCase;
16-
1715
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
1816
import com.sun.jna.platform.win32.Variant.VARIANT;
1917
import com.sun.jna.platform.win32.WinDef.SHORT;
2018

19+
import junit.framework.TestCase;
20+
2121
/**
2222
* @author Tobias Wolf, wolf.tobias@gmx.net
2323
*/

contrib/platform/test/com/sun/jna/platform/win32/W32FileMonitorTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected void setUp() throws Exception {
3939
events = new HashMap<Integer, FileEvent>();
4040
final FileListener listener = new FileListener() {
4141
public void fileChanged(FileEvent e) {
42-
events.put(new Integer(e.getType()), e);
42+
events.put(Integer.valueOf(e.getType()), e);
4343
}
4444
};
4545
monitor = FileMonitor.getInstance();
@@ -190,7 +190,7 @@ private void assertFileEventCreated(final File expectedFile)
190190
private FileEvent waitForFileEvent(final int expectedFileEvent)
191191
throws InterruptedException {
192192

193-
final Integer expectedFileEventInteger = new Integer(expectedFileEvent);
193+
final Integer expectedFileEventInteger = Integer.valueOf(expectedFileEvent);
194194

195195
FileEvent actualEvent = (FileEvent)events.get(expectedFileEventInteger);
196196
final long start = System.currentTimeMillis();

contrib/x11/src/jnacontrib/x11/api/X.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public void fromXModifierKeymap(X11.XModifierKeymapRef xModifierKeymapRef) {
455455
for (int keyNr = 0; keyNr < count; keyNr++) {
456456
byte key = keys[modNr*count + keyNr];
457457
if (key != 0) {
458-
modifier.add(new Byte(key));
458+
modifier.add(Byte.valueOf(key));
459459
}
460460
}
461461
}

contrib/x11/src/jnacontrib/x11/demos/XDesktopDemo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ private void refreshDesktopsAndWindows() throws X.X11Exception {
229229
X.Window window = windows[i];
230230
X.Window.Geometry geo = window.getGeometry();
231231
int windowId = window.getID();
232-
data[i][0] = String.format("0x%08X", new Object[]{new Integer(windowId)});
232+
data[i][0] = String.format("0x%08X", new Object[]{Integer.valueOf(windowId)});
233233
data[i][1] = "" + window.getDesktop();
234234
data[i][2] = window.getTitle();
235235
data[i][3] = "" + geo.x;

src/com/sun/jna/CallbackParameterContext.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
2-
*
2+
*
33
* This library is free software; you can redistribute it and/or
44
* modify it under the terms of the GNU Lesser General Public
55
* License as published by the Free Software Foundation; either
66
* version 2.1 of the License, or (at your option) any later version.
7-
*
7+
*
88
* This library is distributed in the hope that it will be useful,
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11-
* Lesser General Public License for more details.
11+
* Lesser General Public License for more details.
1212
*/
1313
package com.sun.jna;
1414

@@ -19,7 +19,7 @@ public class CallbackParameterContext extends FromNativeContext {
1919
private Method method;
2020
private Object[] args;
2121
private int index;
22-
CallbackParameterContext(Class javaType, Method m, Object[] args, int index) {
22+
CallbackParameterContext(Class<?> javaType, Method m, Object[] args, int index) {
2323
super(javaType);
2424
this.method = m;
2525
this.args = args;

src/com/sun/jna/CallbackProxy.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* This library is distributed in the hope that it will be useful,
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11-
* Lesser General Public License for more details.
11+
* Lesser General Public License for more details.
1212
*/
1313
package com.sun.jna;
1414

@@ -19,12 +19,12 @@
1919
*/
2020
public interface CallbackProxy extends Callback {
2121

22-
/** This is the callback method invoked from native code.
22+
/** This is the callback method invoked from native code.
2323
* It must <em>not</em> throw any exceptions whatsoever.
2424
*/
2525
Object callback(Object[] args);
2626
/** Returns the types of the parameters to the callback method. */
27-
Class[] getParameterTypes();
27+
Class<?>[] getParameterTypes();
2828
/** Returns the type of the callback method's return value. */
29-
Class getReturnType();
29+
Class<?> getReturnType();
3030
}

0 commit comments

Comments
 (0)