Skip to content

Commit

Permalink
Move to Java 11 (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
decebals authored Feb 6, 2023
1 parent a8841d9 commit c8a8c2b
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;

import com.sun.org.apache.xerces.internal.impl.Constants;
//import com.sun.org.apache.xerces.internal.impl.Constants;

import ro.pippo.core.PippoRuntimeException;
import ro.pippo.core.util.IoUtils;
Expand All @@ -57,7 +57,7 @@ public void setUp() {
jaxbEngine = new JaxbEngine();

// JDK property to allow printing out information from the limit analyzer
jaxbEngine.setProperty(Constants.JDK_ENTITY_COUNT_INFO, "yes");
// jaxbEngine.setProperty(Constants.JDK_ENTITY_COUNT_INFO, "yes");
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion pippo-core/src/main/java/ro/pippo/core/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void registerTemplateEngine(Class<? extends TemplateEngine> engineClass)
}

try {
TemplateEngine engine = engineClass.newInstance();
TemplateEngine engine = engineClass.getDeclaredConstructor().newInstance();
setTemplateEngine(engine);
} catch (Exception e) {
throw new PippoRuntimeException(e, "Failed to instantiate '{}'", engineClass.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public List<String> getContentTypeSuffixes() {
public ContentTypeEngine registerContentTypeEngine(Class<? extends ContentTypeEngine> engineClass) {
ContentTypeEngine engine;
try {
engine = engineClass.newInstance();
engine = engineClass.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new PippoRuntimeException(e, "Failed to instantiate '{}'", engineClass.getName());
}
Expand Down
4 changes: 2 additions & 2 deletions pippo-core/src/main/java/ro/pippo/core/ParameterValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ public <T> T to(Class<T> classOfT, String pattern) {

public <T, C extends Converter<T>> T convert(Class<C> converterClass, String pattern) {
try {
C converter = converterClass.newInstance();
C converter = converterClass.getDeclaredConstructor().newInstance();
return converter.getAsObject(values, locale, pattern);
} catch (InstantiationException | IllegalAccessException e) {
} catch (Exception e) {
throw new PippoRuntimeException(e, "Failed to convert");
}
}
Expand Down
4 changes: 2 additions & 2 deletions pippo-core/src/main/java/ro/pippo/core/Pippo.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ protected Application createReloadableApplication(ClassLoader classLoader) {

try {
Class<?> applicationClass = classLoader.loadClass(applicationClassName);
application = (Application) applicationClass.newInstance();
} catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
application = (Application) applicationClass.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new PippoRuntimeException(e);
}

Expand Down
2 changes: 1 addition & 1 deletion pippo-core/src/main/java/ro/pippo/core/PippoFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ protected void createApplication(FilterConfig filterConfig) throws ServletExcept

try {
Class<?> applicationClass = Class.forName(applicationClassName);
application = (Application) applicationClass.newInstance();
application = (Application) applicationClass.getDeclaredConstructor().newInstance();
} catch (Exception e) {
log.error("Cannot create application with className '{}'", applicationClassName, e);
throw new ServletException(e);
Expand Down
2 changes: 1 addition & 1 deletion pippo-core/src/main/java/ro/pippo/core/PippoServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void createApplication(ServletConfig servletConfig) {

try {
Class<?> applicationClass = Class.forName(applicationClassName);
application = (Application) applicationClass.newInstance();
application = (Application) applicationClass.getDeclaredConstructor().newInstance();
} catch (Exception e) {
log.error("Cannot create application with className '{}'", applicationClassName, e);
throw new PippoRuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public DefaultEntityRequestEngine(ContentTypeEngines contentTypeEngines) {
public <T> T createEntityFromParameters(Class<T> entityClass, Request request) {
T entity;
try {
entity = entityClass.newInstance();
entity = entityClass.getDeclaredConstructor().newInstance();
} catch (Exception e) {
log.error("Cannot create new instance of class '{}'", entityClass.getName(), e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Class<?> loadClass(String className, boolean resolve) throws ClassNotFoun
int index = className.lastIndexOf('.');
if (index >= 0) {
String packageName = className.substring(0, index);
if (getPackage(packageName) == null) {
if (getDefinedPackage(packageName) == null) {
try {
definePackage(packageName, null, null, null, null, null, null, null);
} catch (IllegalArgumentException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import ro.pippo.core.Session;
import ro.pippo.core.route.RouteContext;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

/**
* @author Ranganath Kini
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.pac4j.core.context.Cookie;
import org.pac4j.core.context.session.SessionStore;
import ro.pippo.core.Application;
Expand All @@ -43,9 +43,13 @@
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

/**
* @author Ranganath Kini
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ protected ServletContextHandler createPippoHandler() {
// all listeners
listeners.forEach(listener -> {
try {
handler.addEventListener(listener.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
handler.addEventListener(listener.getDeclaredConstructor().newInstance());
} catch (Exception e) {
throw new PippoRuntimeException(e);
}
});
Expand All @@ -221,8 +221,8 @@ protected PippoFilter createPippoFilter() {
try {
// create an instance of JettyWebSocketFilter
Class<?> pippoFilterClass = Class.forName("ro.pippo.jetty.websocket.JettyWebSocketFilter");
return (PippoFilter) pippoFilterClass.newInstance();
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
return (PippoFilter) pippoFilterClass.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new PippoRuntimeException(e);
}
}
Expand Down
6 changes: 2 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.release>11</maven.compiler.release>
<jaxb.version>2.3.1</jaxb.version>
<xml.bind.version>2.3.0.1</xml.bind.version>

Expand All @@ -53,7 +53,7 @@
<metrics.version>4.0.2</metrics.version>

<junit.version>4.13</junit.version>
<mockito.version>2.24.0</mockito.version>
<mockito.version>5.1.1</mockito.version>
</properties>

<build>
Expand All @@ -63,8 +63,6 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
Expand Down

0 comments on commit c8a8c2b

Please sign in to comment.