mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 08:25:09 -04:00
removed XStream's illegal access warnings
This commit is contained in:
parent
841b190b96
commit
3f061837ac
95
src/main/java/de/neemann/digital/LegalXStream.java
Normal file
95
src/main/java/de/neemann/digital/LegalXStream.java
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Helmut Neemann.
|
||||
* Use of this source code is governed by the GPL v3 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
package de.neemann.digital;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.SingleValueConverter;
|
||||
import com.thoughtworks.xstream.converters.basic.*;
|
||||
import com.thoughtworks.xstream.converters.collections.*;
|
||||
import com.thoughtworks.xstream.converters.enums.EnumConverter;
|
||||
import com.thoughtworks.xstream.converters.extended.*;
|
||||
import com.thoughtworks.xstream.converters.reflection.ExternalizableConverter;
|
||||
import com.thoughtworks.xstream.converters.reflection.ReflectionConverter;
|
||||
import com.thoughtworks.xstream.converters.reflection.SerializableConverter;
|
||||
import com.thoughtworks.xstream.core.JVM;
|
||||
import com.thoughtworks.xstream.core.util.SelfStreamingInstanceChecker;
|
||||
import com.thoughtworks.xstream.io.xml.StaxDriver;
|
||||
|
||||
/**
|
||||
* XStream instance which does not create an illegal access warnings.
|
||||
*/
|
||||
public class LegalXStream extends XStream {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public LegalXStream() {
|
||||
super(new StaxDriver());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConverters() {
|
||||
this.registerConverter((Converter) (new ReflectionConverter(getMapper(), getReflectionProvider())), -20);
|
||||
this.registerConverter((Converter) (new SerializableConverter(getMapper(), getReflectionProvider(), getClassLoaderReference())), -10);
|
||||
this.registerConverter((Converter) (new ExternalizableConverter(getMapper(), getClassLoaderReference())), -10);
|
||||
this.registerConverter((Converter) (new NullConverter()), 10000);
|
||||
this.registerConverter((SingleValueConverter) (new IntConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new FloatConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new DoubleConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new LongConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new ShortConverter()), 0);
|
||||
this.registerConverter((Converter) (new CharConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new BooleanConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new ByteConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new StringConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new StringBufferConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new DateConverter()), 0);
|
||||
this.registerConverter((Converter) (new BitSetConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new URIConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new URLConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new BigIntegerConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new BigDecimalConverter()), 0);
|
||||
this.registerConverter((Converter) (new ArrayConverter(getMapper())), 0);
|
||||
this.registerConverter((Converter) (new CharArrayConverter()), 0);
|
||||
this.registerConverter((Converter) (new CollectionConverter(getMapper())), 0);
|
||||
this.registerConverter((Converter) (new MapConverter(getMapper())), 0);
|
||||
// this.registerConverter((Converter)(new TreeMapConverter(getMapper())), 0);
|
||||
// this.registerConverter((Converter)(new TreeSetConverter(getMapper())), 0);
|
||||
this.registerConverter((Converter) (new SingletonCollectionConverter(getMapper())), 0);
|
||||
this.registerConverter((Converter) (new SingletonMapConverter(getMapper())), 0);
|
||||
// this.registerConverter((Converter)(new PropertiesConverter()), 0);
|
||||
this.registerConverter((Converter) (new EncodedByteArrayConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new FileConverter()), 0);
|
||||
if (JVM.isSQLAvailable()) {
|
||||
this.registerConverter((SingleValueConverter) (new SqlTimestampConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new SqlTimeConverter()), 0);
|
||||
this.registerConverter((SingleValueConverter) (new SqlDateConverter()), 0);
|
||||
}
|
||||
|
||||
// this.registerConverter((Converter)(new DynamicProxyConverter(getMapper(), getClassLoaderReference())), 0);
|
||||
this.registerConverter((SingleValueConverter) (new JavaClassConverter(getClassLoaderReference())), 0);
|
||||
this.registerConverter((Converter) (new JavaMethodConverter(getClassLoaderReference())), 0);
|
||||
this.registerConverter((Converter) (new JavaFieldConverter(getClassLoaderReference())), 0);
|
||||
if (JVM.isAWTAvailable()) {
|
||||
// this.registerConverter((Converter)(new FontConverter(getMapper())), 0);
|
||||
this.registerConverter((Converter) (new ColorConverter()), 0);
|
||||
// this.registerConverter((SingleValueConverter)(new TextAttributeConverter()), 0);
|
||||
}
|
||||
|
||||
if (JVM.isSwingAvailable()) {
|
||||
this.registerConverter((Converter) (new LookAndFeelConverter(getMapper(), getReflectionProvider())), 0);
|
||||
}
|
||||
|
||||
this.registerConverter((SingleValueConverter) (new LocaleConverter()), 0);
|
||||
this.registerConverter((Converter) (new GregorianCalendarConverter()), 0);
|
||||
|
||||
this.registerConverter(new EnumConverter(), 0);
|
||||
|
||||
this.registerConverter((Converter) (new SelfStreamingInstanceChecker(getConverterLookup(), this)), 0);
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ package de.neemann.digital.analyse;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
|
||||
import com.thoughtworks.xstream.io.xml.StaxDriver;
|
||||
import de.neemann.digital.LegalXStream;
|
||||
import de.neemann.digital.analyse.expression.BitSetter;
|
||||
import de.neemann.digital.analyse.expression.Context;
|
||||
import de.neemann.digital.analyse.expression.ExpressionException;
|
||||
@ -101,7 +101,7 @@ public class TruthTable implements Copyable<TruthTable> {
|
||||
|
||||
|
||||
private static XStream getxStream() {
|
||||
XStream xStream = new XStream(new StaxDriver());
|
||||
XStream xStream = new LegalXStream();
|
||||
xStream.alias("truthTable", TruthTable.class);
|
||||
xStream.alias("variable", Variable.class);
|
||||
xStream.aliasAttribute(Variable.class, "identifier", "name");
|
||||
|
@ -7,9 +7,9 @@ package de.neemann.digital.draw.elements;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
|
||||
import com.thoughtworks.xstream.io.xml.StaxDriver;
|
||||
import de.neemann.digital.core.*;
|
||||
import de.neemann.digital.LegalXStream;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.*;
|
||||
import de.neemann.digital.core.arithmetic.BarrelShifterMode;
|
||||
import de.neemann.digital.core.arithmetic.LeftRightFormat;
|
||||
import de.neemann.digital.core.element.*;
|
||||
@ -21,8 +21,8 @@ import de.neemann.digital.core.memory.DataField;
|
||||
import de.neemann.digital.core.memory.DataFieldConverter;
|
||||
import de.neemann.digital.core.memory.rom.ROMManger;
|
||||
import de.neemann.digital.core.wiring.Clock;
|
||||
import de.neemann.digital.draw.graphics.*;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.draw.graphics.*;
|
||||
import de.neemann.digital.draw.model.InverterConfig;
|
||||
import de.neemann.digital.draw.shapes.CustomCircuitShapeType;
|
||||
import de.neemann.digital.draw.shapes.Drawable;
|
||||
@ -63,7 +63,7 @@ public class Circuit implements Copyable<Circuit> {
|
||||
* @return the XStream instance
|
||||
*/
|
||||
public static XStream getxStream() {
|
||||
XStream xStream = new XStream(new StaxDriver());
|
||||
XStream xStream = new LegalXStream();
|
||||
xStream.alias("attributes", ElementAttributes.class);
|
||||
xStream.alias("visualElement", VisualElement.class);
|
||||
xStream.alias("wire", Wire.class);
|
||||
|
@ -7,7 +7,7 @@ package de.neemann.digital.fsm;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
|
||||
import com.thoughtworks.xstream.io.xml.StaxDriver;
|
||||
import de.neemann.digital.LegalXStream;
|
||||
import de.neemann.digital.analyse.TruthTable;
|
||||
import de.neemann.digital.analyse.expression.ExpressionException;
|
||||
import de.neemann.digital.draw.graphics.Graphic;
|
||||
@ -57,7 +57,7 @@ public class FSM {
|
||||
* @return the XStream instance
|
||||
*/
|
||||
public static XStream getxStream() {
|
||||
XStream xStream = new XStream(new StaxDriver());
|
||||
XStream xStream = new LegalXStream();
|
||||
xStream.alias("fsm", FSM.class);
|
||||
xStream.alias("state", State.class);
|
||||
xStream.alias("transition", Transition.class);
|
||||
|
@ -6,7 +6,7 @@
|
||||
package de.neemann.digital.toolchain;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.StaxDriver;
|
||||
import de.neemann.digital.LegalXStream;
|
||||
import de.neemann.digital.builder.tt2.OSExecute;
|
||||
import de.neemann.digital.core.NodeException;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
@ -78,7 +78,7 @@ public final class Configuration {
|
||||
}
|
||||
|
||||
private static XStream getxStream() {
|
||||
final XStream xStream = new XStream(new StaxDriver());
|
||||
final XStream xStream = new LegalXStream();
|
||||
xStream.alias("toolchain", Configuration.class);
|
||||
xStream.aliasAttribute(Configuration.class, "name", "name");
|
||||
xStream.aliasAttribute(Configuration.class, "frequency", "frequency");
|
||||
|
@ -6,10 +6,12 @@
|
||||
package de.neemann.gui.language;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.StaxDriver;
|
||||
import de.neemann.digital.LegalXStream;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -20,7 +22,7 @@ public class Bundle {
|
||||
private final ArrayList<Language> list;
|
||||
|
||||
private static XStream getxStream() {
|
||||
XStream xStream = new XStream(new StaxDriver());
|
||||
XStream xStream = new LegalXStream();
|
||||
xStream.alias("languages", Map.class);
|
||||
xStream.registerConverter(new Resources.MapEntryConverter("string"));
|
||||
return xStream;
|
||||
|
@ -12,11 +12,14 @@ import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
|
||||
import com.thoughtworks.xstream.io.xml.StaxDriver;
|
||||
import de.neemann.digital.LegalXStream;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* Used to store the language keys.
|
||||
@ -24,7 +27,7 @@ import java.util.*;
|
||||
public class Resources {
|
||||
|
||||
private static XStream getxStream() {
|
||||
XStream xStream = new XStream(new StaxDriver());
|
||||
XStream xStream = new LegalXStream();
|
||||
xStream.alias("resources", Map.class);
|
||||
xStream.registerConverter(new MapEntryConverter("string"));
|
||||
return xStream;
|
||||
|
Loading…
x
Reference in New Issue
Block a user