Category: Java

Java, and Cloning Arrays

Java-Evil-Edition-orfjackal_netJust to let you know, in case you find this kind of problem… Java is able to clone uni-dimensional arrays of built-in types, like int, but it is not able to clone multidimensional arrays, as a multidimensional array is an array of arrays, and an array is an object. Not sure this is the explanation, but the truth is… clone is useless in this evil language.

If you want to prove it yourself, just try the following code.

public class TestClone {

    public static void main(String[] args) {

    	int[][] boardM = new int[1][1];
    	int[][] copyM;

    	boardM[0][0] = 1;
    	copyM = boardM.clone();

    	boardM[0][0] = 2;

    	if (copyM[0][0] == boardM[0][0]) {
    		System.err.println("oops?");
    	}

    	int[] boardV = new int[1];
    	int[] copyV;

    	boardV[0] = 1;
    	copyV = boardV.clone();

    	boardV[0] = 2;

    	if (copyV[0] == boardV[0]) {
    		System.err.println("oops, too?");
    	}
    }
}

Java User-Friendness

I can’t see how people say Java is an end-user language, whose applications are for general user usage…

SEVERE: Exception
javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:block"!  (See position 1870:716)
	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:302)
	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
	at org.apache.fop.cli.Main.startFOP(Main.java:174)
	at org.apache.fop.cli.Main.main(Main.java:205)
Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:block"!  (See position 1870:716)
	at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
	... 3 more
Caused by: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:block"!  (See position 1870:716)
	at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
	at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
	at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
	at $Proxy1.invalidChild(Unknown Source)
	at org.apache.fop.fo.FONode.invalidChildError(FONode.java:534)
	at org.apache.fop.fo.flow.Inline.validateChildNode(Inline.java:123)
	at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:267)
	at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
	at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
	at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
	... 4 more

---------

javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:block"!  (See position 1870:716)
	at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
	at org.apache.fop.cli.Main.startFOP(Main.java:174)
	at org.apache.fop.cli.Main.main(Main.java:205)
Caused by: org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:block"!  (See position 1870:716)
	at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
	at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
	at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
	at $Proxy1.invalidChild(Unknown Source)
	at org.apache.fop.fo.FONode.invalidChildError(FONode.java:534)
	at org.apache.fop.fo.flow.Inline.validateChildNode(Inline.java:123)
	at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:267)
	at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
	at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
	at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
	... 4 more
---------
org.apache.fop.fo.ValidationException: "fo:inline" is not a valid child of "fo:block"!  (See position 1870:716)
	at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
	at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
	at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
	at $Proxy1.invalidChild(Unknown Source)
	at org.apache.fop.fo.FONode.invalidChildError(FONode.java:534)
	at org.apache.fop.fo.flow.Inline.validateChildNode(Inline.java:123)
	at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:267)
	at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
	at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1072)
	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
	at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
	at org.apache.fop.cli.Main.startFOP(Main.java:174)
	at org.apache.fop.cli.Main.main(Main.java:205)

Just great. Now I know exactly what to do. Cry!