diff options
14 files changed, 74 insertions, 19 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/cli/InputHandler.java b/fop-core/src/main/java/org/apache/fop/cli/InputHandler.java index 29d1c0c11..d91a80115 100644 --- a/fop-core/src/main/java/org/apache/fop/cli/InputHandler.java +++ b/fop-core/src/main/java/org/apache/fop/cli/InputHandler.java @@ -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()); } } diff --git a/fop-core/src/main/java/org/apache/fop/fo/ElementMappingRegistry.java b/fop-core/src/main/java/org/apache/fop/fo/ElementMappingRegistry.java index 08e960b1d..209e4e22d 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/ElementMappingRegistry.java +++ b/fop-core/src/main/java/org/apache/fop/fo/ElementMappingRegistry.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/render/ImageHandlerRegistry.java b/fop-core/src/main/java/org/apache/fop/render/ImageHandlerRegistry.java index 0a4b5e158..d4d9b89d2 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ImageHandlerRegistry.java +++ b/fop-core/src/main/java/org/apache/fop/render/ImageHandlerRegistry.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/render/RendererFactory.java b/fop-core/src/main/java/org/apache/fop/render/RendererFactory.java index 899beb293..ecfe57af6 100644 --- a/fop-core/src/main/java/org/apache/fop/render/RendererFactory.java +++ b/fop-core/src/main/java/org/apache/fop/render/RendererFactory.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/render/XMLHandlerRegistry.java b/fop-core/src/main/java/org/apache/fop/render/XMLHandlerRegistry.java index 9eae3d5e8..f19fc0ac6 100644 --- a/fop-core/src/main/java/org/apache/fop/render/XMLHandlerRegistry.java +++ b/fop-core/src/main/java/org/apache/fop/render/XMLHandlerRegistry.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/AFPFontConfig.java b/fop-core/src/main/java/org/apache/fop/render/afp/AFPFontConfig.java index 35b2cc3f5..1ebc4b83e 100644 --- a/fop-core/src/main/java/org/apache/fop/render/afp/AFPFontConfig.java +++ b/fop-core/src/main/java/org/apache/fop/render/afp/AFPFontConfig.java @@ -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); diff --git a/fop-core/src/main/java/org/apache/fop/tools/anttasks/RunTest.java b/fop-core/src/main/java/org/apache/fop/tools/anttasks/RunTest.java index 585a0a55c..61be685a2 100644 --- a/fop-core/src/main/java/org/apache/fop/tools/anttasks/RunTest.java +++ b/fop-core/src/main/java/org/apache/fop/tools/anttasks/RunTest.java @@ -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[] { diff --git a/fop-core/src/main/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java b/fop-core/src/main/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java index 395433369..71e85cb80 100644 --- a/fop-core/src/main/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java +++ b/fop-core/src/main/java/org/apache/fop/util/ContentHandlerFactoryRegistry.java @@ -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); } } diff --git a/fop-core/src/main/java/org/apache/fop/util/bitmap/BitmapImageUtil.java b/fop-core/src/main/java/org/apache/fop/util/bitmap/BitmapImageUtil.java index 4bfc74a39..f8a53442f 100644 --- a/fop-core/src/main/java/org/apache/fop/util/bitmap/BitmapImageUtil.java +++ b/fop-core/src/main/java/org/apache/fop/util/bitmap/BitmapImageUtil.java @@ -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(); diff --git a/fop-core/src/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java b/fop-core/src/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java index 17c47743c..edd777a1c 100644 --- a/fop-core/src/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java @@ -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); } diff --git a/fop-core/src/test/java/org/apache/fop/apps/FopConfBuilder.java b/fop-core/src/test/java/org/apache/fop/apps/FopConfBuilder.java index 8dd882d8a..8ad0192d6 100644 --- a/fop-core/src/test/java/org/apache/fop/apps/FopConfBuilder.java +++ b/fop-core/src/test/java/org/apache/fop/apps/FopConfBuilder.java @@ -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); } diff --git a/fop-core/src/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java b/fop-core/src/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java index 15a8ba848..797aa1b79 100644 --- a/fop-core/src/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java +++ b/fop-core/src/test/java/org/apache/fop/render/rtf/rtflib/testdocs/CreateTestDocuments.java @@ -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); diff --git a/fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java b/fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java index ec66080cd..b2d2ecb95 100644 --- a/fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java +++ b/fop-core/src/test/java/org/apache/fop/threading/FOPTestbed.java @@ -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); diff --git a/fop/build.xml b/fop/build.xml index 523b37c5e..057d2e344 100644 --- a/fop/build.xml +++ b/fop/build.xml @@ -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"/> |