Skip to content

Commit edc3314

Browse files
Suppress warnings where appropriate (javac + IDE)
1 parent 1418b0c commit edc3314

File tree

12 files changed

+129
-90
lines changed

12 files changed

+129
-90
lines changed

contrib/platform/src/com/sun/jna/platform/win32/COM/COMLateBindingObject.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ protected VARIANT invoke(String methodName, VARIANT arg1, VARIANT arg2,
337337
}
338338

339339
/**
340+
* @param methodName
341+
* @param dispatch
340342
* @deprecated Use {@link #invokeNoReply(java.lang.String)}
341343
*/
342344
@Deprecated
@@ -345,6 +347,8 @@ protected void invokeNoReply(String methodName, IDispatch dispatch) {
345347
}
346348

347349
/**
350+
* @param methodName
351+
* @param comObject
348352
* @deprecated Use {@link #invokeNoReply(java.lang.String)}
349353
*/
350354
@Deprecated
@@ -366,6 +370,9 @@ protected void invokeNoReply(String methodName, VARIANT arg) {
366370
}
367371

368372
/**
373+
* @param methodName
374+
* @param dispatch
375+
* @param arg
369376
* @deprecated Use {@link #invokeNoReply(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT)}
370377
*/
371378
@Deprecated
@@ -375,6 +382,10 @@ protected void invokeNoReply(String methodName, IDispatch dispatch,
375382
}
376383

377384
/**
385+
* @param methodName
386+
* @param arg2
387+
* @param dispatch
388+
* @param arg1
378389
* @deprecated Use {@link #invokeNoReply(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT[])}
379390
*/
380391
@Deprecated
@@ -385,6 +396,10 @@ protected void invokeNoReply(String methodName, IDispatch dispatch,
385396
}
386397

387398
/**
399+
* @param methodName
400+
* @param arg1
401+
* @param comObject
402+
* @param arg2
388403
* @deprecated Use {@link #invokeNoReply(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT[])}
389404
*/
390405
@Deprecated
@@ -395,6 +410,9 @@ protected void invokeNoReply(String methodName, COMLateBindingObject comObject,
395410
}
396411

397412
/**
413+
* @param methodName
414+
* @param comObject
415+
* @param arg
398416
* @deprecated Use {@link #invokeNoReply(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT)}
399417
*/
400418
@Deprecated
@@ -406,6 +424,9 @@ protected void invokeNoReply(String methodName,
406424

407425

408426
/**
427+
* @param methodName
428+
* @param dispatch
429+
* @param args
409430
* @deprecated Use {@link #invokeNoReply(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT[])}
410431
*/
411432
@Deprecated
@@ -526,6 +547,8 @@ protected void setProperty(String propertyName, Dispatch value) {
526547
}
527548

528549
/**
550+
* @param propertyName
551+
* @param value
529552
* @deprecated Use {@link #setProperty(java.lang.String, com.sun.jna.platform.win32.COM.Dispatch)}
530553
*/
531554
@Deprecated
@@ -587,6 +610,9 @@ protected void setProperty(String propertyName, VARIANT value) {
587610
}
588611

589612
/**
613+
* @param propertyName
614+
* @param iDispatch
615+
* @param value
590616
* @deprecated Use {@link #setProperty(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT)}
591617
*/
592618
@Deprecated
@@ -597,6 +623,9 @@ protected void setProperty(String propertyName, IDispatch iDispatch,
597623
}
598624

599625
/**
626+
* @param propertyName
627+
* @param comObject
628+
* @param value
600629
* @deprecated Use {@link #setProperty(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT)}
601630
*/
602631
@Deprecated
@@ -611,6 +640,7 @@ protected void setProperty(String propertyName,
611640
*
612641
* @return the variant
613642
*/
643+
@SuppressWarnings("deprecation")
614644
public VARIANT toVariant() {
615645
return new VARIANT(this.getIDispatch());
616646
}

contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
5757
import com.sun.jna.ptr.IntByReference;
5858
import com.sun.jna.ptr.PointerByReference;
59+
import java.lang.reflect.InvocationTargetException;
5960

6061
public class CallbackProxy implements IDispatchCallback {
6162
// Helper declarations, initialized to default values by jvm
@@ -85,7 +86,7 @@ public CallbackProxy(ObjectFactory factory, Class<?> comEventCallbackInterface,
8586
public DispatchListener dispatchListener;
8687
Map<DISPID, Method> dsipIdMap;
8788

88-
REFIID createRIID(Class<?> comEventCallbackInterface) {
89+
private REFIID createRIID(Class<?> comEventCallbackInterface) {
8990
ComInterface comInterfaceAnnotation = comEventCallbackInterface.getAnnotation(ComInterface.class);
9091
if (null == comInterfaceAnnotation) {
9192
throw new COMException(
@@ -98,8 +99,9 @@ REFIID createRIID(Class<?> comEventCallbackInterface) {
9899
return new REFIID(new IID(iidStr).getPointer());
99100
}
100101

101-
Map<DISPID, Method> createDispIdMap(Class<?> comEventCallbackInterface) {
102-
Map<DISPID, Method> map = new HashMap<DISPID, Method>();
102+
@SuppressWarnings("deprecation") // ComEventCallback is used here to be backwards compatible
103+
private Map<DISPID, Method> createDispIdMap(Class<?> comEventCallbackInterface) {
104+
Map<DISPID, Method> map = new HashMap<>();
103105

104106
for (Method meth : comEventCallbackInterface.getMethods()) {
105107
ComEventCallback callbackAnnotation = meth.getAnnotation(ComEventCallback.class);
@@ -132,7 +134,7 @@ Map<DISPID, Method> createDispIdMap(Class<?> comEventCallbackInterface) {
132134
return map;
133135
}
134136

135-
int fetchDispIdFromName(ComEventCallback annotation) {
137+
private int fetchDispIdFromName(ComEventCallback annotation) {
136138
// TODO
137139
return -1;
138140
}
@@ -233,7 +235,7 @@ void invokeOnThread(final DISPID dispIdMember, final REFIID riid, LCID lcid, WOR
233235
try {
234236
eventMethod.invoke(comEventCallbackListener, params);
235237
} catch (Exception e) {
236-
List<String> decodedClassNames = new ArrayList<String>(params.length);
238+
List<String> decodedClassNames = new ArrayList<>(params.length);
237239
for (Object o : params) {
238240
if (o == null) {
239241
decodedClassNames.add("NULL");
@@ -299,10 +301,12 @@ public HRESULT QueryInterface(REFIID refid, PointerByReference ppvObject) {
299301
return new HRESULT(WinError.E_NOINTERFACE);
300302
}
301303

304+
@Override
302305
public int AddRef() {
303306
return 0;
304307
}
305308

309+
@Override
306310
public int Release() {
307311
return 0;
308312
}

contrib/platform/src/com/sun/jna/platform/win32/COM/util/Convert.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
package com.sun.jna.platform.win32.COM.util;
2525

26-
import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
2726
import com.sun.jna.platform.win32.OleAuto;
2827
import com.sun.jna.platform.win32.Variant;
2928
import java.lang.reflect.InvocationHandler;
@@ -88,6 +87,7 @@ class Convert {
8887
*
8988
* @return wrapped VARIANT
9089
*/
90+
@SuppressWarnings("deprecation")
9191
public static VARIANT toVariant(Object value) {
9292
if (value instanceof VARIANT) {
9393
return (VARIANT) value;
@@ -298,10 +298,7 @@ public static <T extends IComEnum> T toComEnum(Class<T> enumType, Object value)
298298
return t;
299299
}
300300
}
301-
} catch (NoSuchMethodException e) {
302-
} catch (IllegalAccessException e) {
303-
} catch (IllegalArgumentException e) {
304-
} catch (InvocationTargetException e) {
301+
} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
305302
}
306303
return null;
307304
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public interface OaIdl {
8989
// The DATE Type is defined in localtime and the java Date type always contains
9090
// a a timezone offset, so the difference has to be calculated and can't be
9191
// predetermined
92+
@SuppressWarnings("deprecation")
9293
public static final long DATE_OFFSET = new Date(1899 - 1900, 12 - 1, 30, 0, 0, 0).getTime();
9394

9495
/**
@@ -886,6 +887,7 @@ public void destroy() {
886887
/**
887888
* Implemented to satisfy Closeable interface, delegates to destroy.
888889
*/
890+
@Override
889891
public void close() {
890892
destroy();
891893
}

contrib/platform/test/com/sun/jna/platform/win32/COM/util/ComEventCallbacksObjectFactory_Test.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.junit.Before;
3333
import org.junit.Test;
3434

35-
import com.sun.jna.platform.win32.COM.util.annotation.ComEventCallback;
3635
import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
3736
import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
3837
import com.sun.jna.platform.win32.COM.util.annotation.ComObject;
@@ -119,13 +118,13 @@ interface DWebBrowserEvents2 {
119118

120119
public static final String IID = "{34A715A0-6587-11D0-924A-0020AFC7AC4D}";
121120

122-
@ComEventCallback(dispid = 0x000000fd)
121+
@ComMethod(dispId = 0x000000fd)
123122
void OnQuit();
124123

125-
@ComEventCallback(dispid = 0x000000fc)
124+
@ComMethod(dispId = 0x000000fc)
126125
void NavigateComplete2(IUnknown source, Object url);
127126

128-
@ComEventCallback(dispid = 0x000000fa)
127+
@ComMethod(dispId = 0x000000fa)
129128
void BeforeNavigate2(IUnknown pDisp,
130129
String URL,
131130
long Flags,
@@ -148,6 +147,7 @@ public void errorReceivingCallbackEvent(String message, Exception exception) {
148147

149148
volatile boolean blockNavigate = false;
150149

150+
@Override
151151
public void BeforeNavigate2(
152152
IUnknown pDisp,
153153
String URL,
@@ -215,6 +215,7 @@ public void errorReceivingCallbackEvent(String message, Exception exception) {
215215

216216
volatile boolean blockNavigate = false;
217217

218+
@Override
218219
public void BeforeNavigate2(
219220
IUnknown pDisp,
220221
String URL,
@@ -303,6 +304,7 @@ public void unadvise_Quit() throws InterruptedException {
303304
}
304305

305306
@Test
307+
@SuppressWarnings("SleepWhileInLoop")
306308
public void adviseNavigateComplete2() throws InterruptedException {
307309
ComInternetExplorer ieApp = factory.createObject(ComInternetExplorer.class);
308310
ComIWebBrowser2 iWebBrowser2 = ieApp.queryInterface(ComIWebBrowser2.class);
@@ -328,6 +330,7 @@ public void adviseNavigateComplete2() throws InterruptedException {
328330
}
329331

330332
@Test
333+
@SuppressWarnings("SleepWhileInLoop")
331334
public void adviseBeforeNavigate() throws InterruptedException {
332335
ComInternetExplorer ieApp = factory.createObject(ComInternetExplorer.class);
333336
ComIWebBrowser2 iWebBrowser2 = ieApp.queryInterface(ComIWebBrowser2.class);
@@ -424,6 +427,7 @@ interface ComIWebBrowser2WithoutConnectionPoint extends IUnknown {
424427
}
425428

426429
@Test
430+
@SuppressWarnings("SleepWhileInLoop")
427431
public void adviseNavigateComplete2WithoutConnectionPoint() throws InterruptedException {
428432
ComInternetExplorerWithoutConnectionPoint ieApp = factory.createObject(ComInternetExplorerWithoutConnectionPoint.class);
429433
ComIWebBrowser2WithoutConnectionPoint iWebBrowser2 = ieApp.queryInterface(ComIWebBrowser2WithoutConnectionPoint.class);

contrib/platform/test/com/sun/jna/platform/win32/COM/util/ConvertTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,13 @@ public void testConvertFloat() {
270270
}
271271

272272
@Test
273+
@SuppressWarnings("deprecation")
273274
public void testConvertDate() {
274275
testConvertDate(new Date(2015 - 1900, 1, 1, 9, 0, 0));
275276
}
276277

277278
@Test
279+
@SuppressWarnings("deprecation")
278280
public void testConvertDstOffsetTime() {
279281
TimeZone timeZone = TimeZone.getDefault();
280282
try {
@@ -288,6 +290,7 @@ public void testConvertDstOffsetTime() {
288290
}
289291

290292
@Test
293+
@SuppressWarnings("deprecation")
291294
public void testConvertMillisecondTime() {
292295
testConvertDate(new Date(2015 - 1900, 1, 1, 0, 0, 0), 1);
293296
testConvertDate(new Date(2015 - 1900, 1, 1, 0, 0, 0), 499);
@@ -375,6 +378,7 @@ private TestEnum(long val) {
375378
this.value = val;
376379
}
377380

381+
@Override
378382
public long getValue() {
379383
return this.value;
380384
}

contrib/platform/test/com/sun/jna/platform/win32/COM/util/HybdridCOMInvocationTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import com.sun.jna.platform.win32.Variant.VARIANT;
4646
import com.sun.jna.platform.win32.WTypes;
4747
import com.sun.jna.platform.win32.WinDef;
48-
import com.sun.jna.platform.win32.WinDef.UINT;
4948
import com.sun.jna.platform.win32.WinDef.WORD;
5049
import com.sun.jna.platform.win32.WinNT.HRESULT;
5150
import com.sun.jna.ptr.IntByReference;
@@ -176,7 +175,7 @@ public void testOfficeInvocationDemonstration() {
176175
hr = dp.Invoke(dispId, new REFIID(Guid.IID_NULL), LOCALE_SYSTEM_DEFAULT, wFlagsCombined, pDispParams, result, pExcepInfo, puArgErr);
177176
assertTrue(COMUtils.SUCCEEDED(hr));
178177

179-
assertEquals(72.0f, result.floatValue());
178+
assertEquals(72.0f, result.floatValue(), 0.1d);
180179
}
181180

182181
@ComObject(clsId = CLSID_WORD_STRING)
@@ -197,7 +196,7 @@ public WordApplication(boolean useActiveInstance) {
197196

198197
public Float InchesToPoints(Float value) {
199198
VARIANT.ByReference pvResult = new VARIANT.ByReference();
200-
this.oleMethod(OleAuto.DISPATCH_METHOD , pvResult, this.getIDispatch(), "InchesToPoints", new VARIANT[] {new VARIANT(value)});
199+
this.oleMethod(OleAuto.DISPATCH_METHOD , pvResult, "InchesToPoints", new VARIANT[] {new VARIANT(value)});
201200
return pvResult.floatValue();
202201
}
203202
}

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@
3434
import com.sun.jna.Pointer;
3535
import com.sun.jna.Structure;
3636
import com.sun.jna.platform.win32.WTypes.LPSTR;
37+
3738
import static com.sun.jna.platform.win32.WinCrypt.CERT_QUERY_CONTENT_FLAG_ALL;
3839
import static com.sun.jna.platform.win32.WinCrypt.CERT_QUERY_CONTENT_FLAG_PFX_AND_LOAD;
3940
import static com.sun.jna.platform.win32.WinCrypt.CERT_QUERY_FORMAT_FLAG_ALL;
4041
import static com.sun.jna.platform.win32.WinCrypt.CERT_QUERY_OBJECT_FILE;
4142
import static com.sun.jna.platform.win32.WinCrypt.PKCS_7_ASN_ENCODING;
4243
import static com.sun.jna.platform.win32.WinCrypt.X509_ASN_ENCODING;
44+
4345
import com.sun.jna.platform.win32.WinCryptUtil.MANAGED_CRYPT_SIGN_MESSAGE_PARA;
4446
import com.sun.jna.win32.W32APIOptions;
4547

@@ -52,6 +54,7 @@
5254
import java.math.BigInteger;
5355
import java.nio.file.Files;
5456
import java.nio.file.Path;
57+
import java.security.cert.CertificateException;
5558
import java.util.Arrays;
5659
import java.util.Date;
5760
import java.util.List;
@@ -71,6 +74,7 @@
7174
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
7275
import org.bouncycastle.jce.provider.BouncyCastleProvider;
7376
import org.bouncycastle.operator.ContentSigner;
77+
import org.bouncycastle.operator.OperatorCreationException;
7478
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
7579

7680
/**
@@ -675,6 +679,7 @@ private boolean createTestCertificate() {
675679
return true;
676680
}
677681

682+
@SuppressWarnings("deprecation")
678683
private Path createTestCrl() {
679684
try {
680685
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
@@ -695,14 +700,8 @@ private Path createTestCrl() {
695700
crlBuilder.addExtension(Extension.cRLNumber, false, new CRLNumber(new BigInteger("2")));
696701
X509CRLHolder holder = crlBuilder.build(caSigner);
697702

698-
OutputStream fos = null;
699-
try {
700-
fos = Files.newOutputStream(tempFile);
703+
try (OutputStream fos = Files.newOutputStream(tempFile)) {
701704
fos.write(holder.getEncoded());
702-
} finally {
703-
if (fos != null) {
704-
fos.close();
705-
}
706705
}
707706

708707
return tempFile;

0 commit comments

Comments
 (0)