diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index a4c768e022..7faeaebf17 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -16,7 +16,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
- java: [8, 11, 17, 19, 20-ea]
+ java: [8, 11, 17, 21]
os: [ubuntu-latest, macos-latest]
# Run all tests even if one fails
fail-fast: false
diff --git a/CHANGES.md b/CHANGES.md
index 1048cf3dc5..2d498a2ad4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -24,6 +24,8 @@ Important Changes
-----------------
* The interfaces between Java and native code have changed, so `libjnidispatch`
must be rebuilt to be compatible with this release.
+* Release drops support for JDKs 6 + 7, so you'll need at least JDK 8 to
+ update to use this version.
Release (5.13.0)
================
diff --git a/build-ant-tools.xml b/build-ant-tools.xml
index bb73fc7462..8248b0bddb 100644
--- a/build-ant-tools.xml
+++ b/build-ant-tools.xml
@@ -1,5 +1,6 @@
+
Builds and tests JNA
@@ -8,6 +9,7 @@
destdir="${build}/ant-tools"
includeantruntime="false"
encoding="UTF-8"
+ release="${javac.release}"
>
diff --git a/build.xml b/build.xml
index 1b668ce707..c8b6f55499 100644
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,6 @@
Builds and tests JNA
@@ -13,8 +12,7 @@
support it).
Cross-compile by specifying -Dos.prefix={name-arch} to ant
- (cross-compile currently only configured/tested on w32ce-arm and
- android targets)
+ (cross-compile currently only configured/tested on android targets)
Use ANT_OPTS=-D-native=true to build native parts, or directly
invoke the native or test targets
@@ -33,7 +31,7 @@
-
+
@@ -55,74 +53,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -189,19 +120,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -238,9 +156,6 @@
-
-
-
@@ -256,68 +171,8 @@
/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -352,7 +207,7 @@
- Java version ${java.version}, compatibility: ${compatibility}, ant: ${ant.java.version}
+ Java version ${java.version}, compatibility: ${javac.release}, ant: ${ant.java.version}
JNA version ${jna.version}, native ${jni.version}, android ${android.versionCode}
${java.vm.name} (${java.vm.vendor}, ${java.vm.version})
java.home=${java.home}
@@ -406,8 +261,7 @@
replace='VERSION_NATIVE = "${jni.version}";'
file="${build}/jna-src/com/sun/jna/Version.java"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -786,8 +625,9 @@ osname=macosx;processor=aarch64
-
-
+
+
+
@@ -1189,11 +1029,10 @@ cd ..
description="Compile test code which does not have additional native
dependencies">
-
- Checking JDK compatibility 1.6
-
-
-
-
-
-
-
-
-
-
-
- Build is not Java 6 compatible and NOT A PRODUCTION BUILD
-
-
-
@@ -1429,12 +1251,8 @@ cd ..
-
-
-
-
-
-
+
+
@@ -1492,7 +1310,7 @@ cd ..
JNA API Documentation
${footer}
-
+
diff --git a/common.xml b/common.xml
new file mode 100644
index 0000000000..d126afcb0c
--- /dev/null
+++ b/common.xml
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/contrib/platform/build.xml b/contrib/platform/build.xml
index 167d39cabf..d13e636a8e 100644
--- a/contrib/platform/build.xml
+++ b/contrib/platform/build.xml
@@ -2,117 +2,119 @@
Builds and tests platform-specific code.
-
-
+
+
+
- -init-macrodef-javac: defines macro for javac compilation
- -init-macrodef-junit: defines macro for junit execution
- -init-macrodef-debug: defines macro for class debugging
- -init-macrodef-java: defines macro for class execution
- -do-jar-with-manifest: JAR building (if you are using a manifest)
- -do-jar-without-manifest: JAR building (if you are not using a manifest)
- run: execution of project
- -javadoc-build: Javadoc generation
- test-report: JUnit report generation
+
+
+
+
+
- An example of overriding the target for project execution could look like this:
+
-
-
-
-
-
+
- Notice that the overridden target depends on the jar target and not only on
- the compile target as the regular run target does. Again, for a list of available
- properties which you can use, check the target you are overriding in the
- nbproject/build-impl.xml file.
+
+
+
+
- -->
+
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -178,21 +180,37 @@ com.sun.jna.platform.wince;version="${osgi.version}";uses:="com.s
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
-
-
-
+
+
+
-
-
-
-
-
- Checking JDK compatibility 1.6
-
-
-
-
-
-
-
-
-
-
-
- Build is not Java 6 compatible and NOT A PRODUCTION BUILD
-
-
-
- Running platform tests: ${test.src.dir}
+
+ Running platform tests: ${test.src}
+
+
+
-
-
+
+
Saving test results in ${results.junit}
-
+
+
+
+
+
+
-
+
+
+
+
+
+
-
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
@@ -284,6 +308,7 @@ com.sun.jna.platform.wince;version="${osgi.version}";uses:="com.s
+ tests.include=${tests.include}
tests.platform.mac=${tests.platform.mac}
tests.platform.windows=${tests.platform.windows}
tests.platform.linux=${tests.platform.linux}
@@ -291,7 +316,8 @@ com.sun.jna.platform.wince;version="${osgi.version}";uses:="com.s
-
+
+
@@ -301,13 +327,13 @@ com.sun.jna.platform.wince;version="${osgi.version}";uses:="com.s
-
+
-
+
-
+
@@ -325,12 +351,4 @@ com.sun.jna.platform.wince;version="${osgi.version}";uses:="com.s
One or more tests failed
-
-
-
-
-
-
-
-
diff --git a/contrib/platform/nbproject/build-impl.xml b/contrib/platform/nbproject/build-impl.xml
deleted file mode 100644
index 50e512324a..0000000000
--- a/contrib/platform/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1420 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No tests executed.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
- Must select some files in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
- Must select one file in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/contrib/platform/nbproject/ide-file-targets.xml b/contrib/platform/nbproject/ide-file-targets.xml
new file mode 100644
index 0000000000..4d439b0c36
--- /dev/null
+++ b/contrib/platform/nbproject/ide-file-targets.xml
@@ -0,0 +1,93 @@
+
+
+
+ Must set property 'run.class'
+
+
+
+
+
+
+
+
+
+
+
+ Must set property 'debug.class'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set property 'run.class'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set property 'debug.class'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set property 'tests.include.fullpath'
+
+
+
+ test.includes: ${tests.include}
+
+
+
+
+
+
+
+ Must set property 'tests.include.fullpath'
+
+
+
+ test.includes: ${tests.include}
+
+
+
+
+
+
+
+
+
+
diff --git a/contrib/platform/nbproject/project.properties b/contrib/platform/nbproject/project.properties
deleted file mode 100644
index fe6ceb7564..0000000000
--- a/contrib/platform/nbproject/project.properties
+++ /dev/null
@@ -1,103 +0,0 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.processors.list=
-annotation.processing.run.all.processors=true
-application.args=
-application.title=jna-platform
-application.vendor=JNA project
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-debug.classpath=\
- ${run.classpath}
-debug.modulepath=\
- ${run.modulepath}
-debug.test.classpath=\
- ${run.test.classpath}
-debug.test.modulepath=\
- ${run.test.modulepath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/jna-platform.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-endorsed.classpath=
-excludes=
-file.reference.bcpkix-jdk15on-161.jar=../../lib/test/bcpkix-jdk15on-161.jar
-file.reference.bcprov-jdk15on-161.jar=../../lib/test/bcprov-jdk15on-161.jar
-file.reference.hamcrest-core-1.3.jar=../../lib/hamcrest-core-1.3.jar
-file.reference.jna.jar=../../build/jna.jar
-file.reference.jna-test.jar=../../build/jna-test.jar
-file.reference.junit.jar=../../lib/junit.jar
-includes=**
-javac.external.vm=false
-javac.modulepath=
-javac.processormodulepath=
-javac.processorpath=\
- ${javac.classpath}
-javac.test.modulepath=\
- ${javac.modulepath}
-javadoc.html5=false
-jlink.launcher=false
-jlink.launcher.name=platform
-jar.compress=false
-javac.classpath=\
- ${file.reference.jna.jar}
-# Space-separated list of extra javac options
-javac.compilerargs=-XDignore.symbol.file
-javac.deprecation=false
-javac.source=1.6
-javac.target=1.6
-javac.test.classpath=\
- ${javac.classpath}:\
- ${file.reference.jna-test.jar}:\
- ${build.classes.dir}:\
- ${file.reference.junit.jar}:\
- ${file.reference.hamcrest-core-1.3.jar}:\
- ${file.reference.bcpkix-jdk15on-161.jar}:\
- ${file.reference.bcprov-jdk15on-161.jar}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-main.class=
-manifest.file=manifest.mf
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=false
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.modulepath=\
- ${javac.modulepath}
-run.test.classpath=\
- ${javac.test.classpath}:\
- ../../lib/test/reflections-0.9.11.jar:\
- ../../lib/test/guava-27.1-jre.jar:\
- ../../lib/test/javassist-3.12.1.GA.jar:\
- ../../lib/test/slf4j-api-1.6.1.jar:\
- ../../lib/test/dom4j-1.6.1.jar:\
- ${build.test.classes.dir}
-run.test.modulepath=\
- ${javac.test.modulepath}
-src.dir=src
-test.src.dir=test
-source.encoding=UTF-8
-file.encoding=UTF-8
diff --git a/contrib/platform/nbproject/project.xml b/contrib/platform/nbproject/project.xml
index 94a0dfa0be..1a14a7faae 100644
--- a/contrib/platform/nbproject/project.xml
+++ b/contrib/platform/nbproject/project.xml
@@ -1,16 +1,164 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- platform
- 1.6.5
-
-
-
-
-
-
-
-
-
+
+
+ org.netbeans.modules.ant.freeform
+
+
+ platform
+
+
+
+ platform
+
+
+
+
+ java
+ src
+ UTF-8
+
+
+
+ java
+ test
+ UTF-8
+
+
+
+
+ compile-tests
+ jar
+
+
+ clean
+
+
+ test
+
+
+ clean
+ compile-tests
+ jar
+
+
+
+ run-selected-file-in-src
+
+ run.class
+ src
+ \.java$
+ java-name
+
+
+
+
+
+
+
+ debug-selected-file-in-src
+
+ debug.class
+ src
+ \.java$
+ java-name
+
+
+
+
+
+
+
+ debug-selected-file-in-test
+
+ debug.class
+ test
+ \.java$
+ java-name
+
+
+
+
+
+
+
+ run-selected-file-in-test
+
+ run.class
+ test
+ \.java$
+ java-name
+
+
+
+
+
+
+
+ test-single
+
+ tests.include.fullpath
+ test
+ \.java$
+ absolute-path
+
+
+
+
+
+
+
+ debug-test-single
+
+ tests.include.fullpath
+ test
+ \.java$
+ absolute-path
+
+
+
+
+
+
+
+
+
+
+ src
+
+
+
+ test
+
+
+ build.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ src
+ ../../build/jna.jar
+ 1.8
+
+
+ test
+
+ src:../../build/jna.jar:../../build/jna-test.jar:../../build/test-classes:../../lib/junit.jar:../../lib/hamcrest-core-1.3.jar:../../lib/test/bcpkix-jdk15on-161.jar:../../lib/test/bcprov-jdk15on-161.jar
+ 1.8
+
+
+
+
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMLateBindingObject.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMLateBindingObject.java
index 43ab72ce48..ec54d31d95 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMLateBindingObject.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMLateBindingObject.java
@@ -337,6 +337,8 @@ protected VARIANT invoke(String methodName, VARIANT arg1, VARIANT arg2,
}
/**
+ * @param methodName
+ * @param dispatch
* @deprecated Use {@link #invokeNoReply(java.lang.String)}
*/
@Deprecated
@@ -345,6 +347,8 @@ protected void invokeNoReply(String methodName, IDispatch dispatch) {
}
/**
+ * @param methodName
+ * @param comObject
* @deprecated Use {@link #invokeNoReply(java.lang.String)}
*/
@Deprecated
@@ -366,6 +370,9 @@ protected void invokeNoReply(String methodName, VARIANT arg) {
}
/**
+ * @param methodName
+ * @param dispatch
+ * @param arg
* @deprecated Use {@link #invokeNoReply(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT)}
*/
@Deprecated
@@ -375,6 +382,10 @@ protected void invokeNoReply(String methodName, IDispatch dispatch,
}
/**
+ * @param methodName
+ * @param arg2
+ * @param dispatch
+ * @param arg1
* @deprecated Use {@link #invokeNoReply(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT[])}
*/
@Deprecated
@@ -385,6 +396,10 @@ protected void invokeNoReply(String methodName, IDispatch dispatch,
}
/**
+ * @param methodName
+ * @param arg1
+ * @param comObject
+ * @param arg2
* @deprecated Use {@link #invokeNoReply(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT[])}
*/
@Deprecated
@@ -395,6 +410,9 @@ protected void invokeNoReply(String methodName, COMLateBindingObject comObject,
}
/**
+ * @param methodName
+ * @param comObject
+ * @param arg
* @deprecated Use {@link #invokeNoReply(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT)}
*/
@Deprecated
@@ -406,6 +424,9 @@ protected void invokeNoReply(String methodName,
/**
+ * @param methodName
+ * @param dispatch
+ * @param args
* @deprecated Use {@link #invokeNoReply(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT[])}
*/
@Deprecated
@@ -526,6 +547,8 @@ protected void setProperty(String propertyName, Dispatch value) {
}
/**
+ * @param propertyName
+ * @param value
* @deprecated Use {@link #setProperty(java.lang.String, com.sun.jna.platform.win32.COM.Dispatch)}
*/
@Deprecated
@@ -587,6 +610,9 @@ protected void setProperty(String propertyName, VARIANT value) {
}
/**
+ * @param propertyName
+ * @param iDispatch
+ * @param value
* @deprecated Use {@link #setProperty(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT)}
*/
@Deprecated
@@ -597,6 +623,9 @@ protected void setProperty(String propertyName, IDispatch iDispatch,
}
/**
+ * @param propertyName
+ * @param comObject
+ * @param value
* @deprecated Use {@link #setProperty(java.lang.String, com.sun.jna.platform.win32.Variant.VARIANT)}
*/
@Deprecated
@@ -611,6 +640,7 @@ protected void setProperty(String propertyName,
*
* @return the variant
*/
+ @SuppressWarnings("deprecation")
public VARIANT toVariant() {
return new VARIANT(this.getIDispatch());
}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java
index bc05fc1bbc..58c91b77fd 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java
@@ -56,6 +56,7 @@
import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
+import java.lang.reflect.InvocationTargetException;
public class CallbackProxy implements IDispatchCallback {
// Helper declarations, initialized to default values by jvm
@@ -85,7 +86,7 @@ public CallbackProxy(ObjectFactory factory, Class> comEventCallbackInterface,
public DispatchListener dispatchListener;
Map dsipIdMap;
- REFIID createRIID(Class> comEventCallbackInterface) {
+ private REFIID createRIID(Class> comEventCallbackInterface) {
ComInterface comInterfaceAnnotation = comEventCallbackInterface.getAnnotation(ComInterface.class);
if (null == comInterfaceAnnotation) {
throw new COMException(
@@ -98,8 +99,9 @@ REFIID createRIID(Class> comEventCallbackInterface) {
return new REFIID(new IID(iidStr).getPointer());
}
- Map createDispIdMap(Class> comEventCallbackInterface) {
- Map map = new HashMap();
+ @SuppressWarnings("deprecation") // ComEventCallback is used here to be backwards compatible
+ private Map createDispIdMap(Class> comEventCallbackInterface) {
+ Map map = new HashMap<>();
for (Method meth : comEventCallbackInterface.getMethods()) {
ComEventCallback callbackAnnotation = meth.getAnnotation(ComEventCallback.class);
@@ -132,7 +134,7 @@ Map createDispIdMap(Class> comEventCallbackInterface) {
return map;
}
- int fetchDispIdFromName(ComEventCallback annotation) {
+ private int fetchDispIdFromName(ComEventCallback annotation) {
// TODO
return -1;
}
@@ -233,7 +235,7 @@ void invokeOnThread(final DISPID dispIdMember, final REFIID riid, LCID lcid, WOR
try {
eventMethod.invoke(comEventCallbackListener, params);
} catch (Exception e) {
- List decodedClassNames = new ArrayList(params.length);
+ List decodedClassNames = new ArrayList<>(params.length);
for (Object o : params) {
if (o == null) {
decodedClassNames.add("NULL");
@@ -299,10 +301,12 @@ public HRESULT QueryInterface(REFIID refid, PointerByReference ppvObject) {
return new HRESULT(WinError.E_NOINTERFACE);
}
+ @Override
public int AddRef() {
return 0;
}
+ @Override
public int Release() {
return 0;
}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/Convert.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/Convert.java
index 3884fec55b..60b696408b 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/Convert.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/Convert.java
@@ -23,7 +23,6 @@
*/
package com.sun.jna.platform.win32.COM.util;
-import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
import com.sun.jna.platform.win32.OleAuto;
import com.sun.jna.platform.win32.Variant;
import java.lang.reflect.InvocationHandler;
@@ -88,6 +87,7 @@ class Convert {
*
* @return wrapped VARIANT
*/
+ @SuppressWarnings("deprecation")
public static VARIANT toVariant(Object value) {
if (value instanceof VARIANT) {
return (VARIANT) value;
@@ -298,10 +298,7 @@ public static T toComEnum(Class enumType, Object value)
return t;
}
}
- } catch (NoSuchMethodException e) {
- } catch (IllegalAccessException e) {
- } catch (IllegalArgumentException e) {
- } catch (InvocationTargetException e) {
+ } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
}
return null;
}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java b/contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java
index c6c6929b34..2cfd896162 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java
@@ -89,6 +89,7 @@ public interface OaIdl {
// The DATE Type is defined in localtime and the java Date type always contains
// a a timezone offset, so the difference has to be calculated and can't be
// predetermined
+ @SuppressWarnings("deprecation")
public static final long DATE_OFFSET = new Date(1899 - 1900, 12 - 1, 30, 0, 0, 0).getTime();
/**
@@ -886,6 +887,7 @@ public void destroy() {
/**
* Implemented to satisfy Closeable interface, delegates to destroy.
*/
+ @Override
public void close() {
destroy();
}
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ComEventCallbacksObjectFactory_Test.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ComEventCallbacksObjectFactory_Test.java
index fe01225b9f..b95387f55f 100644
--- a/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ComEventCallbacksObjectFactory_Test.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ComEventCallbacksObjectFactory_Test.java
@@ -32,7 +32,6 @@
import org.junit.Before;
import org.junit.Test;
-import com.sun.jna.platform.win32.COM.util.annotation.ComEventCallback;
import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
import com.sun.jna.platform.win32.COM.util.annotation.ComObject;
@@ -119,13 +118,13 @@ interface DWebBrowserEvents2 {
public static final String IID = "{34A715A0-6587-11D0-924A-0020AFC7AC4D}";
- @ComEventCallback(dispid = 0x000000fd)
+ @ComMethod(dispId = 0x000000fd)
void OnQuit();
- @ComEventCallback(dispid = 0x000000fc)
+ @ComMethod(dispId = 0x000000fc)
void NavigateComplete2(IUnknown source, Object url);
- @ComEventCallback(dispid = 0x000000fa)
+ @ComMethod(dispId = 0x000000fa)
void BeforeNavigate2(IUnknown pDisp,
String URL,
long Flags,
@@ -148,6 +147,7 @@ public void errorReceivingCallbackEvent(String message, Exception exception) {
volatile boolean blockNavigate = false;
+ @Override
public void BeforeNavigate2(
IUnknown pDisp,
String URL,
@@ -215,6 +215,7 @@ public void errorReceivingCallbackEvent(String message, Exception exception) {
volatile boolean blockNavigate = false;
+ @Override
public void BeforeNavigate2(
IUnknown pDisp,
String URL,
@@ -303,6 +304,7 @@ public void unadvise_Quit() throws InterruptedException {
}
@Test
+ @SuppressWarnings("SleepWhileInLoop")
public void adviseNavigateComplete2() throws InterruptedException {
ComInternetExplorer ieApp = factory.createObject(ComInternetExplorer.class);
ComIWebBrowser2 iWebBrowser2 = ieApp.queryInterface(ComIWebBrowser2.class);
@@ -328,6 +330,7 @@ public void adviseNavigateComplete2() throws InterruptedException {
}
@Test
+ @SuppressWarnings("SleepWhileInLoop")
public void adviseBeforeNavigate() throws InterruptedException {
ComInternetExplorer ieApp = factory.createObject(ComInternetExplorer.class);
ComIWebBrowser2 iWebBrowser2 = ieApp.queryInterface(ComIWebBrowser2.class);
@@ -424,6 +427,7 @@ interface ComIWebBrowser2WithoutConnectionPoint extends IUnknown {
}
@Test
+ @SuppressWarnings("SleepWhileInLoop")
public void adviseNavigateComplete2WithoutConnectionPoint() throws InterruptedException {
ComInternetExplorerWithoutConnectionPoint ieApp = factory.createObject(ComInternetExplorerWithoutConnectionPoint.class);
ComIWebBrowser2WithoutConnectionPoint iWebBrowser2 = ieApp.queryInterface(ComIWebBrowser2WithoutConnectionPoint.class);
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ConvertTest.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ConvertTest.java
index 915e7bc6d7..ea1061080f 100644
--- a/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ConvertTest.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ConvertTest.java
@@ -270,11 +270,13 @@ public void testConvertFloat() {
}
@Test
+ @SuppressWarnings("deprecation")
public void testConvertDate() {
testConvertDate(new Date(2015 - 1900, 1, 1, 9, 0, 0));
}
@Test
+ @SuppressWarnings("deprecation")
public void testConvertDstOffsetTime() {
TimeZone timeZone = TimeZone.getDefault();
try {
@@ -288,6 +290,7 @@ public void testConvertDstOffsetTime() {
}
@Test
+ @SuppressWarnings("deprecation")
public void testConvertMillisecondTime() {
testConvertDate(new Date(2015 - 1900, 1, 1, 0, 0, 0), 1);
testConvertDate(new Date(2015 - 1900, 1, 1, 0, 0, 0), 499);
@@ -375,6 +378,7 @@ private TestEnum(long val) {
this.value = val;
}
+ @Override
public long getValue() {
return this.value;
}
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/util/HybdridCOMInvocationTest.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/util/HybdridCOMInvocationTest.java
index c51b29b780..59813439b8 100644
--- a/contrib/platform/test/com/sun/jna/platform/win32/COM/util/HybdridCOMInvocationTest.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/util/HybdridCOMInvocationTest.java
@@ -45,7 +45,6 @@
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WTypes;
import com.sun.jna.platform.win32.WinDef;
-import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinDef.WORD;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
@@ -176,7 +175,7 @@ public void testOfficeInvocationDemonstration() {
hr = dp.Invoke(dispId, new REFIID(Guid.IID_NULL), LOCALE_SYSTEM_DEFAULT, wFlagsCombined, pDispParams, result, pExcepInfo, puArgErr);
assertTrue(COMUtils.SUCCEEDED(hr));
- assertEquals(72.0f, result.floatValue());
+ assertEquals(72.0f, result.floatValue(), 0.1d);
}
@ComObject(clsId = CLSID_WORD_STRING)
@@ -197,7 +196,7 @@ public WordApplication(boolean useActiveInstance) {
public Float InchesToPoints(Float value) {
VARIANT.ByReference pvResult = new VARIANT.ByReference();
- this.oleMethod(OleAuto.DISPATCH_METHOD , pvResult, this.getIDispatch(), "InchesToPoints", new VARIANT[] {new VARIANT(value)});
+ this.oleMethod(OleAuto.DISPATCH_METHOD , pvResult, "InchesToPoints", new VARIANT[] {new VARIANT(value)});
return pvResult.floatValue();
}
}
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Crypt32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Crypt32Test.java
index 11ca96a732..dece01e0bc 100644
--- a/contrib/platform/test/com/sun/jna/platform/win32/Crypt32Test.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/Crypt32Test.java
@@ -34,12 +34,14 @@
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WTypes.LPSTR;
+
import static com.sun.jna.platform.win32.WinCrypt.CERT_QUERY_CONTENT_FLAG_ALL;
import static com.sun.jna.platform.win32.WinCrypt.CERT_QUERY_CONTENT_FLAG_PFX_AND_LOAD;
import static com.sun.jna.platform.win32.WinCrypt.CERT_QUERY_FORMAT_FLAG_ALL;
import static com.sun.jna.platform.win32.WinCrypt.CERT_QUERY_OBJECT_FILE;
import static com.sun.jna.platform.win32.WinCrypt.PKCS_7_ASN_ENCODING;
import static com.sun.jna.platform.win32.WinCrypt.X509_ASN_ENCODING;
+
import com.sun.jna.platform.win32.WinCryptUtil.MANAGED_CRYPT_SIGN_MESSAGE_PARA;
import com.sun.jna.win32.W32APIOptions;
@@ -52,6 +54,7 @@
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.security.cert.CertificateException;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -71,6 +74,7 @@
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.operator.ContentSigner;
+import org.bouncycastle.operator.OperatorCreationException;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
/**
@@ -675,6 +679,7 @@ private boolean createTestCertificate() {
return true;
}
+ @SuppressWarnings("deprecation")
private Path createTestCrl() {
try {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
@@ -695,14 +700,8 @@ private Path createTestCrl() {
crlBuilder.addExtension(Extension.cRLNumber, false, new CRLNumber(new BigInteger("2")));
X509CRLHolder holder = crlBuilder.build(caSigner);
- OutputStream fos = null;
- try {
- fos = Files.newOutputStream(tempFile);
+ try (OutputStream fos = Files.newOutputStream(tempFile)) {
fos.write(holder.getEncoded());
- } finally {
- if (fos != null) {
- fos.close();
- }
}
return tempFile;
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Kernel32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Kernel32Test.java
index f8b6971c3e..f7dc4ffebc 100644
--- a/contrib/platform/test/com/sun/jna/platform/win32/Kernel32Test.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/Kernel32Test.java
@@ -119,7 +119,7 @@ public void testGetLastErrorNativeLibraryOverride() {
// see https://github.com/twall/jna/issues/482
public void testNoDuplicateMethodsNames() {
Collection dupSet = AbstractWin32TestSupport.detectDuplicateMethods(Kernel32.class);
- if (dupSet.size() > 0) {
+ if (!dupSet.isEmpty()) {
for (String name : new String[]{
// has 2 overloads by design since the API accepts both OSVERSIONINFO and OSVERSIONINFOEX
"GetVersionEx",
@@ -648,11 +648,8 @@ public void testReadFile() throws IOException {
File tmp = File.createTempFile("testReadFile", "jna");
tmp.deleteOnExit();
- FileWriter fw = new FileWriter(tmp);
- try {
+ try (FileWriter fw = new FileWriter(tmp)) {
fw.append(expected);
- } finally {
- fw.close();
}
HANDLE hFile = Kernel32.INSTANCE.CreateFile(tmp.getAbsolutePath(), WinNT.GENERIC_READ, WinNT.FILE_SHARE_READ,
@@ -786,9 +783,7 @@ public void testDeviceIoControlFsctlReparse() throws IOException {
File delLink = link.toFile();
delLink.deleteOnExit();
- // Required for FSCTL_SET_REPARSE_POINT
- Advapi32Util.Privilege restore = new Advapi32Util.Privilege(WinNT.SE_RESTORE_NAME);
- try {
+ try (Advapi32Util.Privilege restore = new Advapi32Util.Privilege(WinNT.SE_RESTORE_NAME)) { // Required for FSCTL_SET_REPARSE_POINT
restore.enable();
HANDLE hFile = Kernel32.INSTANCE.CreateFile(link.toAbsolutePath().toString(),
WinNT.GENERIC_READ | WinNT.FILE_WRITE_ATTRIBUTES | WinNT.FILE_WRITE_EA,
@@ -839,9 +834,6 @@ public void testDeviceIoControlFsctlReparse() throws IOException {
Kernel32Util.closeHandle(hFile);
}
}
- finally {
- restore.close();
- }
}
public void testCopyFile() throws IOException {
@@ -908,19 +900,19 @@ public void testFindFirstFile() throws IOException {
// Get data and confirm the 1st name is . for the directory itself.
WIN32_FIND_DATA fd = new WIN32_FIND_DATA(p);
- String actualFileName = new String(fd.getFileName());
+ String actualFileName = fd.getFileName();
assertTrue(actualFileName.contentEquals("."));
// Get data and confirm the 2nd name is .. for the directory's parent
assertTrue(Kernel32.INSTANCE.FindNextFile(hFile, p));
fd = new WIN32_FIND_DATA(p);
- actualFileName = new String(fd.getFileName());
+ actualFileName = fd.getFileName();
assertTrue(actualFileName.contentEquals(".."));
// Get data and confirm the 3rd name is the tmp file name
assertTrue(Kernel32.INSTANCE.FindNextFile(hFile, p));
fd = new WIN32_FIND_DATA(p);
- actualFileName = new String(fd.getFileName());
+ actualFileName = fd.getFileName();
assertTrue(actualFileName.contentEquals(tmpFile.getName()));
// No more files in directory
@@ -951,19 +943,19 @@ public void testFindFirstFileExFindExInfoStandard() throws IOException {
// Get data and confirm the 1st name is . for the directory itself.
WIN32_FIND_DATA fd = new WIN32_FIND_DATA(p);
- String actualFileName = new String(fd.getFileName());
+ String actualFileName = fd.getFileName();
assertTrue(actualFileName.contentEquals("."));
// Get data and confirm the 2nd name is .. for the directory's parent
assertTrue(Kernel32.INSTANCE.FindNextFile(hFile, p));
fd = new WIN32_FIND_DATA(p);
- actualFileName = new String(fd.getFileName());
+ actualFileName = fd.getFileName();
assertTrue(actualFileName.contentEquals(".."));
// Get data and confirm the 3rd name is the tmp file name
assertTrue(Kernel32.INSTANCE.FindNextFile(hFile, p));
fd = new WIN32_FIND_DATA(p);
- actualFileName = new String(fd.getFileName());
+ actualFileName = fd.getFileName();
assertTrue(actualFileName.contentEquals(tmpFile.getName()));
// No more files in directory
@@ -994,8 +986,7 @@ public void testFindFirstFileExFindExInfoBasic() throws IOException {
try {
// Get data and confirm the 1st name is for the file itself
WIN32_FIND_DATA fd = new WIN32_FIND_DATA(p);
- String actualFileName = new String(fd.getFileName());
- actualFileName = new String(fd.getFileName());
+ String actualFileName = fd.getFileName();
assertTrue(actualFileName.contentEquals(tmpFile.getName()));
// FindExInfoBasic does not return the short name, so confirm that its empty
@@ -1126,6 +1117,7 @@ public void testSetFileInformationByHandleFileDispositionInfo() throws IOExcepti
assertFalse(Files.exists(Paths.get(tmp.getAbsolutePath())));
}
+ @SuppressWarnings("deprecation")
public void testGetSetFileTime() throws IOException {
File tmp = File.createTempFile("testGetSetFileTime", "jna");
tmp.deleteOnExit();
@@ -1168,7 +1160,7 @@ public void testGetProcessList() throws IOException {
assertTrue(Kernel32.INSTANCE.Process32First(processEnumHandle, processEntry));
- List processIdList = new ArrayList();
+ List processIdList = new ArrayList<>();
processIdList.add(processEntry.th32ProcessID.longValue());
while (Kernel32.INSTANCE.Process32Next(processEnumHandle, processEntry)) {
@@ -1190,7 +1182,7 @@ public void testGetThreadList() throws IOException {
assertTrue(Kernel32.INSTANCE.Thread32First(threadEnumHandle, threadEntry));
- List threadIdList = new ArrayList();
+ List threadIdList = new ArrayList<>();
threadIdList.add(threadEntry.th32ThreadID);
while (Kernel32.INSTANCE.Thread32Next(threadEnumHandle, threadEntry)) {
@@ -1206,10 +1198,10 @@ public void testGetThreadList() throws IOException {
public final void testGetPrivateProfileInt() throws IOException {
final File tmp = File.createTempFile("testGetPrivateProfileInt", "ini");
tmp.deleteOnExit();
- final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
- writer.println("[Section]");
- writer.println("existingKey = 123");
- writer.close();
+ try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)))) {
+ writer.println("[Section]");
+ writer.println("existingKey = 123");
+ }
assertEquals(123, Kernel32.INSTANCE.GetPrivateProfileInt("Section", "existingKey", 456, tmp.getCanonicalPath()));
assertEquals(456, Kernel32.INSTANCE.GetPrivateProfileInt("Section", "missingKey", 456, tmp.getCanonicalPath()));
@@ -1218,10 +1210,10 @@ public final void testGetPrivateProfileInt() throws IOException {
public final void testGetPrivateProfileString() throws IOException {
final File tmp = File.createTempFile("testGetPrivateProfileString", ".ini");
tmp.deleteOnExit();
- final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
- writer.println("[Section]");
- writer.println("existingKey = ABC");
- writer.close();
+ try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)))) {
+ writer.println("[Section]");
+ writer.println("existingKey = ABC");
+ }
final char[] buffer = new char[8];
@@ -1237,11 +1229,11 @@ public final void testGetPrivateProfileString() throws IOException {
public final void testWritePrivateProfileString() throws IOException {
final File tmp = File.createTempFile("testWritePrivateProfileString", ".ini");
tmp.deleteOnExit();
- final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
- writer.println("[Section]");
- writer.println("existingKey = ABC");
- writer.println("removedKey = JKL");
- writer.close();
+ try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)))) {
+ writer.println("[Section]");
+ writer.println("existingKey = ABC");
+ writer.println("removedKey = JKL");
+ }
assertTrue(Kernel32.INSTANCE.WritePrivateProfileString("Section", "existingKey", "DEF", tmp.getCanonicalPath()));
assertTrue(Kernel32.INSTANCE.WritePrivateProfileString("Section", "addedKey", "GHI", tmp.getCanonicalPath()));
@@ -1259,13 +1251,10 @@ public final void testGetPrivateProfileSection() throws IOException {
final File tmp = File.createTempFile("testGetPrivateProfileSection", ".ini");
tmp.deleteOnExit();
- final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
- try {
+ try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)))) {
writer.println("[X]");
writer.println("A=1");
writer.println("B=X");
- } finally {
- writer.close();
}
final char[] buffer = new char[9];
@@ -1279,12 +1268,9 @@ public final void testGetPrivateProfileSectionNames() throws IOException {
final File tmp = File.createTempFile("testGetPrivateProfileSectionNames", ".ini");
tmp.deleteOnExit();
- final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
- try {
+ try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)))) {
writer.println("[S1]");
writer.println("[S2]");
- } finally {
- writer.close();
}
final char[] buffer = new char[7];
@@ -1297,23 +1283,20 @@ public final void testWritePrivateProfileSection() throws IOException {
final File tmp = File.createTempFile("testWritePrivateProfileSection", ".ini");
tmp.deleteOnExit();
- final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
- try {
+ try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)))) {
writer.println("[S1]");
writer.println("A=1");
writer.println("B=X");
- } finally {
- writer.close();
}
final boolean result = Kernel32.INSTANCE.WritePrivateProfileSection("S1", "A=3\0E=Z\0\0", tmp.getCanonicalPath());
assertTrue(result);
- final BufferedReader reader = new BufferedReader(new FileReader(tmp));
- assertEquals(reader.readLine(), "[S1]");
- assertTrue(reader.readLine().matches("A\\s*=\\s*3"));
- assertTrue(reader.readLine().matches("E\\s*=\\s*Z"));
- reader.close();
+ try (BufferedReader reader = new BufferedReader(new FileReader(tmp))) {
+ assertEquals(reader.readLine(), "[S1]");
+ assertTrue(reader.readLine().matches("A\\s*=\\s*3"));
+ assertTrue(reader.readLine().matches("E\\s*=\\s*Z"));
+ }
}
/**
@@ -1710,7 +1693,7 @@ public boolean invoke(HMODULE module, Pointer type, Pointer name, Pointer lParam
public void testEnumResourceTypes() {
- final List types = new ArrayList();
+ final List types = new ArrayList<>();
WinBase.EnumResTypeProc ertp = new WinBase.EnumResTypeProc() {
@Override
@@ -1732,7 +1715,7 @@ public boolean invoke(HMODULE module, Pointer type, Pointer lParam) {
boolean result = Kernel32.INSTANCE.EnumResourceTypes(null, ertp, null);
assertTrue("EnumResourceTypes should not have failed.", result);
assertEquals("GetLastError should be set to 0", WinError.ERROR_SUCCESS, Kernel32.INSTANCE.GetLastError());
- assertTrue("EnumResourceTypes should return some resource type names", types.size() > 0);
+ assertTrue("EnumResourceTypes should return some resource type names", !types.isEmpty());
}
public void testModule32FirstW() {
@@ -1976,12 +1959,9 @@ public void testCreateFileMapping() throws IOException {
File testFile = File.createTempFile("jna-test", ".txt");
try {
- OutputStream os = new FileOutputStream(testFile);
- try {
+ try (OutputStream os = new FileOutputStream(testFile)) {
os.write(testString.getBytes("UTF-8"));
os.write(0);
- } finally {
- os.close();
}
SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO();
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/SAFEARRAYTest.java b/contrib/platform/test/com/sun/jna/platform/win32/SAFEARRAYTest.java
index b5b7621b76..a7e6d356e6 100644
--- a/contrib/platform/test/com/sun/jna/platform/win32/SAFEARRAYTest.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/SAFEARRAYTest.java
@@ -25,7 +25,6 @@
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
-import static com.sun.jna.platform.win32.AbstractWin32TestSupport.checkCOMRegistered;
import com.sun.jna.platform.win32.COM.COMException;
import com.sun.jna.platform.win32.COM.COMUtils;
import com.sun.jna.platform.win32.COM.util.ObjectFactory;
@@ -61,21 +60,21 @@
import java.util.Date;
import java.util.List;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
-import org.junit.After;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import org.junit.Before;
import static com.sun.jna.platform.win32.OaIdlUtil.toPrimitiveArray;
import com.sun.jna.platform.win32.WTypes.VARTYPE;
import com.sun.jna.platform.win32.WinDef.LONG;
import java.lang.reflect.Field;
-import org.junit.Assume;
public class SAFEARRAYTest {
static {
@@ -273,6 +272,7 @@ public void testMultidimensionalNotNullBased() {
}
@Test
+ @SuppressWarnings("deprecation")
public void testDataTypes() {
int idx = 1;
Pointer dataPointer;
@@ -518,8 +518,8 @@ public void testADODB() {
recordset.Open("SELECT TOP 5 System.ItemPathDisplay, System.ItemName, System.ItemUrl, System.DateCreated FROM SYSTEMINDEX ORDER BY System.ItemUrl", conn, CursorTypeEnum.adOpenUnspecified, LockTypeEnum.adLockUnspecified, -1);
// Save complete list for comparison with subscript list
- List urls = new ArrayList(5);
- List names = new ArrayList(5);
+ List urls = new ArrayList<>(5);
+ List names = new ArrayList<>(5);
while (!recordset.getEOF()) {
WinNT.HRESULT hr;
@@ -774,7 +774,7 @@ public static enum CursorTypeEnum implements IComEnum {
private CursorTypeEnum(long value) {
this.value = value;
}
- private long value;
+ private final long value;
@Override
public long getValue() {
@@ -796,7 +796,7 @@ public static enum LockTypeEnum implements IComEnum {
private LockTypeEnum(long value) {
this.value = value;
}
- private long value;
+ private final long value;
@Override
public long getValue() {
@@ -831,6 +831,10 @@ public static interface _Connection {
/**
*
* memberId(10)
+ * @param ConnectionString
+ * @param UserID
+ * @param Password
+ * @param Options
*/
@ComMethod(name = "Open")
void Open(String ConnectionString,
@@ -851,6 +855,7 @@ public static interface _Recordset {
/**
*
* memberId(1006)
+ * @return
*/
@ComProperty(name = "EOF")
Boolean getEOF();
@@ -858,6 +863,10 @@ public static interface _Recordset {
/**
*
* memberId(1016)
+ * @param Rows
+ * @param Start
+ * @param Fields
+ * @return
*/
@ComMethod(name = "GetRows")
SAFEARRAY GetRows(int Rows,
@@ -867,6 +876,8 @@ SAFEARRAY GetRows(int Rows,
/**
*
* memberId(1016)
+ * @param Rows
+ * @return
*/
@ComMethod(name = "GetRows")
SAFEARRAY GetRows(int Rows);
@@ -874,6 +885,7 @@ SAFEARRAY GetRows(int Rows,
/**
*
* memberId(1016)
+ * @return
*/
@ComMethod(name = "GetRows")
SAFEARRAY GetRows();
@@ -888,6 +900,11 @@ SAFEARRAY GetRows(int Rows,
/**
*
* memberId(1022)
+ * @param Source
+ * @param ActiveConnection
+ * @param CursorType
+ * @param LockType
+ * @param Options
*/
@ComMethod(name = "Open")
void Open(Object Source,
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/VariantTest.java b/contrib/platform/test/com/sun/jna/platform/win32/VariantTest.java
index d034875cb4..4ab8c162a7 100644
--- a/contrib/platform/test/com/sun/jna/platform/win32/VariantTest.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/VariantTest.java
@@ -112,6 +112,7 @@ public void testVariantRecord() {
pvRecord2 = (VARIANT._VARIANT.__VARIANT.BRECORD)variant.getValue();
}
+ @SuppressWarnings("deprecation")
public void testDATECalculation() {
// Samples from MSDN to ensure correct implementation
// Definition is to be found here: https://msdn.microsoft.com/de-de/library/82ab7w69.aspx
@@ -164,6 +165,7 @@ public void testDATECalculation() {
testDate, new DATE(testDate).getAsJavaDate());
}
+ @SuppressWarnings("deprecation")
public void testVariantConstructors() {
VARIANT variant;
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/WTypesTest.java b/contrib/platform/test/com/sun/jna/platform/win32/WTypesTest.java
index ba482d5540..a235731a81 100644
--- a/contrib/platform/test/com/sun/jna/platform/win32/WTypesTest.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/WTypesTest.java
@@ -69,6 +69,7 @@ public void testLPWSTRConstruction() {
assertEquals(fromPointer.getValue(), TEST_STRING);
}
+ @SuppressWarnings("deprecation")
public void testBSTRBasic() {
String demoString = "input\u00D6\u00E4\u00DC?!";
// Allocation via system and the "correct" way
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Win32ServiceDemo.java b/contrib/platform/test/com/sun/jna/platform/win32/Win32ServiceDemo.java
index 99200fd8da..a77fa51e4b 100644
--- a/contrib/platform/test/com/sun/jna/platform/win32/Win32ServiceDemo.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/Win32ServiceDemo.java
@@ -78,6 +78,7 @@ public static void main(String[] args) {
SUFFIXES.add("jna.jar");
SUFFIXES.add("jna-test.jar");
SUFFIXES.add("classes");
+ SUFFIXES.add("test-classes");
}
private final Object waitObject = new Object();
diff --git a/nbproject/ide-file-targets.xml b/nbproject/ide-file-targets.xml
index 149419762a..4d439b0c36 100644
--- a/nbproject/ide-file-targets.xml
+++ b/nbproject/ide-file-targets.xml
@@ -62,4 +62,32 @@
+
+
+ Must set property 'tests.include.fullpath'
+
+
+
+ test.includes: ${tests.include}
+
+
+
+
+
+
+
+ Must set property 'tests.include.fullpath'
+
+
+
+ test.includes: ${tests.include}
+
+
+
+
+
+
+
+
+
diff --git a/nbproject/project.xml b/nbproject/project.xml
index c05eefc132..e284dbe752 100644
--- a/nbproject/project.xml
+++ b/nbproject/project.xml
@@ -41,6 +41,7 @@ auxiliary.show.customizer.message=
+ compile-tests
jar
@@ -54,6 +55,7 @@ auxiliary.show.customizer.message=
clean
+ compile-tests
jar
@@ -108,6 +110,32 @@ auxiliary.show.customizer.message=
+
+
+ test-single
+
+ tests.include.fullpath
+ test
+ \.java$
+ absolute-path
+
+
+
+
+
+
+
+ debug-test-single
+
+ tests.include.fullpath
+ test
+ \.java$
+ absolute-path
+
+
+
+
+
@@ -141,7 +169,7 @@ auxiliary.show.customizer.message=
src
src
- 1.6
+ 1.8
test
@@ -152,7 +180,7 @@ auxiliary.show.customizer.message=
ant-tools-src
src:lib/ant.jar:lib/asm-8.0.1.jar
- 1.6
+ 1.8
diff --git a/src/com/sun/jna/Function.java b/src/com/sun/jna/Function.java
index b4182024f3..a4fd26ff85 100644
--- a/src/com/sun/jna/Function.java
+++ b/src/com/sun/jna/Function.java
@@ -81,7 +81,7 @@ public interface PostCallRead {
public static final int USE_VARARGS = 0xFF;
/** Offset of USE_VARARGS in call flags */
@java.lang.annotation.Native
- public static final int USE_VARARGS_SHIFT = 7;
+ private static final int USE_VARARGS_SHIFT = 7;
static final Integer INTEGER_TRUE = Integer.valueOf(-1);
static final Integer INTEGER_FALSE = Integer.valueOf(0);