Skip to content

Commit 53854c9

Browse files
Replace deprecated Class#newInstance calls
1 parent 52569b6 commit 53854c9

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Features
99
--------
1010
* [#1029](https://github.com/java-native-access/jna/issues/1029): Add `statvfs` to `c.s.j.platform.linux.LibC` - [@dbwiddis](https://github.com/dbwiddis).
1111
* [#1032](https://github.com/java-native-access/jna/pull/1032): Deprecate `c.s.j.platform.win32.COM.util.annotation.ComEventCallback` in favour of `c.s.j.platform.win32.COM.util.annotation.ComMethod` - [@matthiasblaesing](https://github.com/matthiasblaesing).
12+
* [#1033](https://github.com/java-native-access/jna/pull/1033): Replace deprecated Class#newInstance calls
1213

1314
Bug Fixes
1415
---------

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void testCorrectDeclarationOfMembers() throws InstantiationException, Ill
118118
if(Structure.class.isAssignableFrom(klass)) {
119119
boolean writeWorked = false;
120120
try {
121-
Structure struct = (Structure) klass.newInstance();
121+
Structure struct = Structure.newInstance((Class<? extends Structure>) klass);
122122
struct.write();
123123
writeWorked = true;
124124
} catch (java.lang.Throwable ex) {

test/com/sun/jna/StructureTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private void testAlignStruct(String prefix,int index) {
390390
IntByReference offset = new IntByReference();
391391
LongByReference value = new LongByReference();
392392
Class<?> cls = Class.forName(getClass().getName() + "$" + prefix + "TestStructure" + index);
393-
Structure s = (Structure)cls.newInstance();
393+
Structure s = Structure.newInstance((Class<? extends Structure>) cls);
394394
int result = lib.testStructureAlignment(s, index, offset, value);
395395
assertEquals("Wrong native value at field " + result
396396
+ "=0x" + Long.toHexString(value.getValue())

test/com/sun/jna/WebStartTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ private static void sendResults(Throwable t, int port) throws IOException {
417417
}
418418

419419
private static Throwable runTestCaseTest(String testClass, String method, int port) throws Exception {
420-
TestCase test = (TestCase)Class.forName(testClass).newInstance();
420+
TestCase test = (TestCase)Class.forName(testClass).getConstructor().newInstance();
421421
test.setName(method);
422422
TestResult result = new TestResult();
423423
test.run(result);

0 commit comments

Comments
 (0)