Skip to content

Commit 0daf9ff

Browse files
authored
Fix javaJaxRS template: remove deprecated in JDK9 method usage (#18728)
* Fix javaJaxRS template: remove deprecated in JDK9 method usage * Fix javaJaxRS api template: regenerate samples
1 parent 728abaf commit 0daf9ff

File tree

26 files changed

+26
-26
lines changed

26 files changed

+26
-26
lines changed

modules/openapi-generator/src/main/resources/JavaJaxRS/api.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class {{classname}} {
4747
String implClass = servletContext.getInitParameter("{{classname}}.implementation");
4848
if (implClass != null && !"".equals(implClass.trim())) {
4949
try {
50-
delegate = ({{classname}}Service) Class.forName(implClass).newInstance();
50+
delegate = ({{classname}}Service) Class.forName(implClass).getDeclaredConstructor().newInstance();
5151
} catch (Exception e) {
5252
throw new RuntimeException(e);
5353
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/AnotherFakeApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public AnotherFakeApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("AnotherFakeApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (AnotherFakeApiService) Class.forName(implClass).newInstance();
44+
delegate = (AnotherFakeApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/FakeApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public FakeApi(@Context ServletConfig servletContext) {
5050
String implClass = servletContext.getInitParameter("FakeApi.implementation");
5151
if (implClass != null && !"".equals(implClass.trim())) {
5252
try {
53-
delegate = (FakeApiService) Class.forName(implClass).newInstance();
53+
delegate = (FakeApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
5454
} catch (Exception e) {
5555
throw new RuntimeException(e);
5656
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/FakeClassnameTestApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public FakeClassnameTestApi(@Context ServletConfig servletContext) {
4040
String implClass = servletContext.getInitParameter("FakeClassnameTestApi.implementation");
4141
if (implClass != null && !"".equals(implClass.trim())) {
4242
try {
43-
delegate = (FakeClassnameTestApiService) Class.forName(implClass).newInstance();
43+
delegate = (FakeClassnameTestApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4444
} catch (Exception e) {
4545
throw new RuntimeException(e);
4646
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/PetApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public PetApi(@Context ServletConfig servletContext) {
4343
String implClass = servletContext.getInitParameter("PetApi.implementation");
4444
if (implClass != null && !"".equals(implClass.trim())) {
4545
try {
46-
delegate = (PetApiService) Class.forName(implClass).newInstance();
46+
delegate = (PetApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4747
} catch (Exception e) {
4848
throw new RuntimeException(e);
4949
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/StoreApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public StoreApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("StoreApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (StoreApiService) Class.forName(implClass).newInstance();
44+
delegate = (StoreApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/UserApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public UserApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("UserApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (UserApiService) Class.forName(implClass).newInstance();
44+
delegate = (UserApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/AnotherFakeApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public AnotherFakeApi(@Context ServletConfig servletContext) {
4040
String implClass = servletContext.getInitParameter("AnotherFakeApi.implementation");
4141
if (implClass != null && !"".equals(implClass.trim())) {
4242
try {
43-
delegate = (AnotherFakeApiService) Class.forName(implClass).newInstance();
43+
delegate = (AnotherFakeApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4444
} catch (Exception e) {
4545
throw new RuntimeException(e);
4646
}

samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public FakeApi(@Context ServletConfig servletContext) {
5555
String implClass = servletContext.getInitParameter("FakeApi.implementation");
5656
if (implClass != null && !"".equals(implClass.trim())) {
5757
try {
58-
delegate = (FakeApiService) Class.forName(implClass).newInstance();
58+
delegate = (FakeApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
5959
} catch (Exception e) {
6060
throw new RuntimeException(e);
6161
}

samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeClassnameTestApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public FakeClassnameTestApi(@Context ServletConfig servletContext) {
4040
String implClass = servletContext.getInitParameter("FakeClassnameTestApi.implementation");
4141
if (implClass != null && !"".equals(implClass.trim())) {
4242
try {
43-
delegate = (FakeClassnameTestApiService) Class.forName(implClass).newInstance();
43+
delegate = (FakeClassnameTestApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4444
} catch (Exception e) {
4545
throw new RuntimeException(e);
4646
}

samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FooApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public FooApi(@Context ServletConfig servletContext) {
4040
String implClass = servletContext.getInitParameter("FooApi.implementation");
4141
if (implClass != null && !"".equals(implClass.trim())) {
4242
try {
43-
delegate = (FooApiService) Class.forName(implClass).newInstance();
43+
delegate = (FooApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4444
} catch (Exception e) {
4545
throw new RuntimeException(e);
4646
}

samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/PetApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public PetApi(@Context ServletConfig servletContext) {
4343
String implClass = servletContext.getInitParameter("PetApi.implementation");
4444
if (implClass != null && !"".equals(implClass.trim())) {
4545
try {
46-
delegate = (PetApiService) Class.forName(implClass).newInstance();
46+
delegate = (PetApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4747
} catch (Exception e) {
4848
throw new RuntimeException(e);
4949
}

samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/StoreApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public StoreApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("StoreApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (StoreApiService) Class.forName(implClass).newInstance();
44+
delegate = (StoreApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/UserApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public UserApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("UserApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (UserApiService) Class.forName(implClass).newInstance();
44+
delegate = (UserApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/AnotherFakeApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public AnotherFakeApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("AnotherFakeApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (AnotherFakeApiService) Class.forName(implClass).newInstance();
44+
delegate = (AnotherFakeApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/FakeApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public FakeApi(@Context ServletConfig servletContext) {
4848
String implClass = servletContext.getInitParameter("FakeApi.implementation");
4949
if (implClass != null && !"".equals(implClass.trim())) {
5050
try {
51-
delegate = (FakeApiService) Class.forName(implClass).newInstance();
51+
delegate = (FakeApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
5252
} catch (Exception e) {
5353
throw new RuntimeException(e);
5454
}

samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/FakeClassnameTags123Api.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public FakeClassnameTags123Api(@Context ServletConfig servletContext) {
4040
String implClass = servletContext.getInitParameter("FakeClassnameTags123Api.implementation");
4141
if (implClass != null && !"".equals(implClass.trim())) {
4242
try {
43-
delegate = (FakeClassnameTags123ApiService) Class.forName(implClass).newInstance();
43+
delegate = (FakeClassnameTags123ApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4444
} catch (Exception e) {
4545
throw new RuntimeException(e);
4646
}

samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/PetApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public PetApi(@Context ServletConfig servletContext) {
4343
String implClass = servletContext.getInitParameter("PetApi.implementation");
4444
if (implClass != null && !"".equals(implClass.trim())) {
4545
try {
46-
delegate = (PetApiService) Class.forName(implClass).newInstance();
46+
delegate = (PetApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4747
} catch (Exception e) {
4848
throw new RuntimeException(e);
4949
}

samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/StoreApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public StoreApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("StoreApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (StoreApiService) Class.forName(implClass).newInstance();
44+
delegate = (StoreApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

samples/server/petstore/jaxrs/jersey2-useTags/src/gen/java/org/openapitools/api/UserApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public UserApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("UserApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (UserApiService) Class.forName(implClass).newInstance();
44+
delegate = (UserApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/AnotherFakeApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public AnotherFakeApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("AnotherFakeApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (AnotherFakeApiService) Class.forName(implClass).newInstance();
44+
delegate = (AnotherFakeApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/FakeApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public FakeApi(@Context ServletConfig servletContext) {
4949
String implClass = servletContext.getInitParameter("FakeApi.implementation");
5050
if (implClass != null && !"".equals(implClass.trim())) {
5151
try {
52-
delegate = (FakeApiService) Class.forName(implClass).newInstance();
52+
delegate = (FakeApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
5353
} catch (Exception e) {
5454
throw new RuntimeException(e);
5555
}

samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/FakeClassnameTestApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public FakeClassnameTestApi(@Context ServletConfig servletContext) {
4040
String implClass = servletContext.getInitParameter("FakeClassnameTestApi.implementation");
4141
if (implClass != null && !"".equals(implClass.trim())) {
4242
try {
43-
delegate = (FakeClassnameTestApiService) Class.forName(implClass).newInstance();
43+
delegate = (FakeClassnameTestApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4444
} catch (Exception e) {
4545
throw new RuntimeException(e);
4646
}

samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/PetApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public PetApi(@Context ServletConfig servletContext) {
4343
String implClass = servletContext.getInitParameter("PetApi.implementation");
4444
if (implClass != null && !"".equals(implClass.trim())) {
4545
try {
46-
delegate = (PetApiService) Class.forName(implClass).newInstance();
46+
delegate = (PetApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4747
} catch (Exception e) {
4848
throw new RuntimeException(e);
4949
}

samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/StoreApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public StoreApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("StoreApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (StoreApiService) Class.forName(implClass).newInstance();
44+
delegate = (StoreApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

samples/server/petstore/jaxrs/jersey2/src/gen/java/org/openapitools/api/UserApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public UserApi(@Context ServletConfig servletContext) {
4141
String implClass = servletContext.getInitParameter("UserApi.implementation");
4242
if (implClass != null && !"".equals(implClass.trim())) {
4343
try {
44-
delegate = (UserApiService) Class.forName(implClass).newInstance();
44+
delegate = (UserApiService) Class.forName(implClass).getDeclaredConstructor().newInstance();
4545
} catch (Exception e) {
4646
throw new RuntimeException(e);
4747
}

0 commit comments

Comments
 (0)