Browse Source

FOP-2643: Java 9 warnings

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1780541 13f79535-47bb-0310-9956-ffa450edef68
pull/57/head
Simon Steiner 7 years ago
parent
commit
bee2a52a96

+ 9
- 2
fop-core/src/main/java/org/apache/fop/cli/InputHandler.java View File

@@ -23,6 +23,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Vector;

import javax.xml.parsers.ParserConfigurationException;
@@ -202,14 +203,20 @@ public class InputHandler implements ErrorListener, Renderable {
return;
}
try {
entityResolver = (EntityResolver) resolverClass.newInstance();
uriResolver = (URIResolver) resolverClass.newInstance();
entityResolver = (EntityResolver) resolverClass.getDeclaredConstructor().newInstance();
uriResolver = (URIResolver) resolverClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException e) {
log.error("Error creating the catalog resolver: " + e.getMessage());
eventProducer.catalogResolverNotCreated(this, e.getMessage());
} catch (IllegalAccessException e) {
log.error("Error creating the catalog resolver: " + e.getMessage());
eventProducer.catalogResolverNotCreated(this, e.getMessage());
} catch (NoSuchMethodException e) {
log.error("Error creating the catalog resolver: " + e.getMessage());
eventProducer.catalogResolverNotCreated(this, e.getMessage());
} catch (InvocationTargetException e) {
log.error("Error creating the catalog resolver: " + e.getMessage());
eventProducer.catalogResolverNotCreated(this, e.getMessage());
}
}


+ 6
- 1
fop-core/src/main/java/org/apache/fop/fo/ElementMappingRegistry.java View File

@@ -19,6 +19,7 @@

package org.apache.fop.fo;

import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.Map;

@@ -94,7 +95,7 @@ public class ElementMappingRegistry {
throws IllegalArgumentException {
try {
ElementMapping mapping
= (ElementMapping)Class.forName(mappingClassName).newInstance();
= (ElementMapping)Class.forName(mappingClassName).getDeclaredConstructor().newInstance();
addElementMapping(mapping);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find "
@@ -108,6 +109,10 @@ public class ElementMappingRegistry {
} catch (ClassCastException e) {
throw new IllegalArgumentException(mappingClassName
+ " is not an ElementMapping");
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}


+ 6
- 1
fop-core/src/main/java/org/apache/fop/render/ImageHandlerRegistry.java View File

@@ -19,6 +19,7 @@

package org.apache.fop.render;

import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
@@ -74,7 +75,7 @@ public class ImageHandlerRegistry {
public void addHandler(String classname) {
try {
ImageHandler handlerInstance
= (ImageHandler)Class.forName(classname).newInstance();
= (ImageHandler)Class.forName(classname).getDeclaredConstructor().newInstance();
addHandler(handlerInstance);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find "
@@ -89,6 +90,10 @@ public class ImageHandlerRegistry {
throw new IllegalArgumentException(classname
+ " is not an "
+ ImageHandler.class.getName());
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}


+ 16
- 3
fop-core/src/main/java/org/apache/fop/render/RendererFactory.java View File

@@ -20,6 +20,7 @@
package org.apache.fop.render;

import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -137,7 +138,7 @@ public class RendererFactory {
public void addRendererMaker(String className) {
try {
AbstractRendererMaker makerInstance
= (AbstractRendererMaker)Class.forName(className).newInstance();
= (AbstractRendererMaker)Class.forName(className).getDeclaredConstructor().newInstance();
addRendererMaker(makerInstance);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find "
@@ -152,6 +153,10 @@ public class RendererFactory {
throw new IllegalArgumentException(className
+ " is not an "
+ AbstractRendererMaker.class.getName());
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}

@@ -163,7 +168,7 @@ public class RendererFactory {
public void addFOEventHandlerMaker(String className) {
try {
AbstractFOEventHandlerMaker makerInstance
= (AbstractFOEventHandlerMaker)Class.forName(className).newInstance();
= (AbstractFOEventHandlerMaker)Class.forName(className).getDeclaredConstructor().newInstance();
addFOEventHandlerMaker(makerInstance);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find "
@@ -178,6 +183,10 @@ public class RendererFactory {
throw new IllegalArgumentException(className
+ " is not an "
+ AbstractFOEventHandlerMaker.class.getName());
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}

@@ -189,7 +198,7 @@ public class RendererFactory {
public void addDocumentHandlerMaker(String className) {
try {
AbstractIFDocumentHandlerMaker makerInstance
= (AbstractIFDocumentHandlerMaker)Class.forName(className).newInstance();
= (AbstractIFDocumentHandlerMaker)Class.forName(className).getDeclaredConstructor().newInstance();
addDocumentHandlerMaker(makerInstance);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find "
@@ -204,6 +213,10 @@ public class RendererFactory {
throw new IllegalArgumentException(className
+ " is not an "
+ AbstractIFDocumentHandlerMaker.class.getName());
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}


+ 6
- 1
fop-core/src/main/java/org/apache/fop/render/XMLHandlerRegistry.java View File

@@ -19,6 +19,7 @@

package org.apache.fop.render;

import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -63,7 +64,7 @@ public class XMLHandlerRegistry {
*/
public void addXMLHandler(String classname) {
try {
XMLHandler handlerInstance = (XMLHandler)Class.forName(classname).newInstance();
XMLHandler handlerInstance = (XMLHandler)Class.forName(classname).getDeclaredConstructor().newInstance();
addXMLHandler(handlerInstance);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find "
@@ -78,6 +79,10 @@ public class XMLHandlerRegistry {
throw new IllegalArgumentException(classname
+ " is not an "
+ XMLHandler.class.getName());
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}


+ 6
- 1
fop-core/src/main/java/org/apache/fop/render/afp/AFPFontConfig.java View File

@@ -20,6 +20,7 @@
package org.apache.fop.render.afp;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -458,13 +459,17 @@ public final class AFPFontConfig implements FontConfig {
try {
Class<? extends Typeface> clazz = Class.forName("org.apache.fop.fonts.base14."
+ base14Name).asSubclass(Typeface.class);
return clazz.newInstance();
return clazz.getDeclaredConstructor().newInstance();
} catch (IllegalAccessException iae) {
LOG.error(iae.getMessage());
} catch (ClassNotFoundException cnfe) {
LOG.error(cnfe.getMessage());
} catch (InstantiationException ie) {
LOG.error(ie.getMessage());
} catch (NoSuchMethodException e) {
LOG.error(e.getMessage());
} catch (InvocationTargetException e) {
LOG.error(e.getMessage());
}
throw new ClassNotFoundException("Couldn't load file for AFP font with base14 name: "
+ base14Name);

+ 1
- 1
fop-core/src/main/java/org/apache/fop/tools/anttasks/RunTest.java View File

@@ -199,7 +199,7 @@ public class RunTest extends Task {
Map diff = null;
try {
Class cla = Class.forName(converter, true, loader);
Object tc = cla.newInstance();
Object tc = cla.getDeclaredConstructor().newInstance();
Method meth;

meth = cla.getMethod("setBaseDir", new Class[] {

+ 6
- 1
fop-core/src/main/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java View File

@@ -19,6 +19,7 @@

package org.apache.fop.util;

import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.Map;

@@ -54,7 +55,7 @@ public class ContentHandlerFactoryRegistry {
public void addContentHandlerFactory(String classname) {
try {
ContentHandlerFactory factory
= (ContentHandlerFactory)Class.forName(classname).newInstance();
= (ContentHandlerFactory)Class.forName(classname).getDeclaredConstructor().newInstance();
addContentHandlerFactory(factory);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find "
@@ -69,6 +70,10 @@ public class ContentHandlerFactoryRegistry {
throw new IllegalArgumentException(classname
+ " is not an "
+ ContentHandlerFactory.class.getName());
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException(e);
}
}


+ 6
- 1
fop-core/src/main/java/org/apache/fop/util/bitmap/BitmapImageUtil.java View File

@@ -28,6 +28,7 @@ import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
import java.awt.image.RenderedImage;
import java.awt.image.WritableRaster;
import java.lang.reflect.InvocationTargetException;

/**
* Utility method for dealing with bitmap images.
@@ -245,7 +246,7 @@ public final class BitmapImageUtil {
try {
String clName = "org.apache.fop.util.bitmap.JAIMonochromeBitmapConverter";
Class clazz = Class.forName(clName);
converter = (MonochromeBitmapConverter)clazz.newInstance();
converter = (MonochromeBitmapConverter)clazz.getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException cnfe) {
// Class was not compiled so is not available. Simply ignore.
} catch (LinkageError le) {
@@ -258,6 +259,10 @@ public final class BitmapImageUtil {
// Problem instantiating the class, simply continue with the backup implementation
} catch (IllegalAccessException e) {
// Problem instantiating the class, simply continue with the backup implementation
} catch (NoSuchMethodException e) {
// Problem instantiating the class, simply continue with the backup implementation
} catch (InvocationTargetException e) {
// Problem instantiating the class, simply continue with the backup implementation
}
if (converter == null) {
converter = new DefaultMonochromeBitmapConverter();

+ 2
- 2
fop-core/src/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java View File

@@ -43,11 +43,11 @@ public class GraphicsCharacterStringTestCase {
CharacterSetBuilder csb = CharacterSetBuilder.getSingleByteInstance();
CharacterSet cs1146 = csb.build("C0H200B0", "T1V10500", "Cp1146",
Class.forName("org.apache.fop.fonts.base14.Helvetica").asSubclass(Typeface.class)
.newInstance(), null);
.getDeclaredConstructor().newInstance(), null);
gcsCp1146 = new GraphicsCharacterString(poundsText, 0, 0, cs1146);
CharacterSet cs500 = csb.build("C0H200B0", "T1V10500", "Cp500",
Class.forName("org.apache.fop.fonts.base14.Helvetica").asSubclass(Typeface.class)
.newInstance(), null);
.getDeclaredConstructor().newInstance(), null);
gcsCp500 = new GraphicsCharacterString(dollarsText, 0, 0, cs500);
}


+ 6
- 1
fop-core/src/test/java/org/apache/fop/apps/FopConfBuilder.java View File

@@ -25,6 +25,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -218,9 +219,13 @@ public class FopConfBuilder implements FontConfigurator<FopConfBuilder> {
*/
public <T extends RendererConfBuilder> T startRendererConfig(Class<T> rendererConfigClass) {
try {
currentRendererConfig = rendererConfigClass.newInstance();
currentRendererConfig = rendererConfigClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}

+ 1
- 1
fop-core/src/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java View File

@@ -72,7 +72,7 @@ public class CreateTestDocuments {
className = TESTDOCS_PACKAGE + "." + className;
TestDocument td = null;
try {
td = (TestDocument)Class.forName(className).newInstance();
td = (TestDocument)Class.forName(className).getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new Exception("unable to instantiate '" + className
+ " as a TestDocument object: " + e);

+ 1
- 1
fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java View File

@@ -177,7 +177,7 @@ public class FOPTestbed extends AbstractLogEnabled
try {
Class clazz = Class.forName(this.fopCfg.getAttribute("class",
"org.apache.fop.threading.FOProcessorImpl"));
Processor fop = (Processor)clazz.newInstance();
Processor fop = (Processor)clazz.getDeclaredConstructor().newInstance();
ContainerUtil.enableLogging(fop, getLogger());
ContainerUtil.configure(fop, this.fopCfg);
ContainerUtil.initialize(fop);

+ 2
- 2
fop/build.xml View File

@@ -160,8 +160,8 @@ list of possible build targets.
<property name="javac.debug" value="on"/>
<property name="javac.optimize" value="off"/>
<property name="javac.deprecation" value="on"/>
<property name="javac.source" value="1.5"/>
<property name="javac.target" value="1.5"/>
<property name="javac.source" value="1.6"/>
<property name="javac.target" value="1.6"/>
<property name="javac.fork" value="no"/>
<property name="junit.fork" value="yes"/>
<property name="junit.haltonfailure" value="off"/>

Loading…
Cancel
Save