Skip to content

Commit

Permalink
use jpl instead of jul
Browse files Browse the repository at this point in the history
clean up
  • Loading branch information
umjammer committed Apr 30, 2024
1 parent b85c237 commit f89c146
Show file tree
Hide file tree
Showing 103 changed files with 913 additions and 1,035 deletions.
23 changes: 6 additions & 17 deletions core/src/main/java/org/jnode/nanoxml/XMLElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;

/**
* XMLElement is a representation of an XML object. The object is able to parse
Expand Down Expand Up @@ -102,8 +100,7 @@
* &lt;<A href="mailto:[email protected]">[email protected]</A>&gt;
* @version $Name$, $Revision: 1950 $
*/
public class XMLElement
{
public class XMLElement {

/**
* Serialization serial version ID.
Expand Down Expand Up @@ -363,9 +360,7 @@ public XMLElement(boolean skipLeadingWhitespace)
* @see XMLElement#XMLElement(java.util.Map)
* XMLElement(Hashtable)
*/
public XMLElement(Map<String, Object> entities,
boolean skipLeadingWhitespace)
{
public XMLElement(Map<String, Object> entities, boolean skipLeadingWhitespace) {
this(entities, skipLeadingWhitespace, true, true);
}

Expand Down Expand Up @@ -404,8 +399,7 @@ public XMLElement(Map<String, Object> entities,
*/
public XMLElement(Map<String, Object> entities,
boolean skipLeadingWhitespace,
boolean ignoreCase)
{
boolean ignoreCase) {
this(entities, skipLeadingWhitespace, true, ignoreCase);
}

Expand Down Expand Up @@ -451,8 +445,7 @@ public XMLElement(Map<String, Object> entities,
protected XMLElement(Map<String, Object> entities,
boolean skipLeadingWhitespace,
boolean fillBasicConversionTable,
boolean ignoreCase)
{
boolean ignoreCase) {
this.ignoreWhitespace = skipLeadingWhitespace;
this.ignoreCase = ignoreCase;
this.name = null;
Expand Down Expand Up @@ -548,9 +541,7 @@ public void addChild(XMLElement child)
* String, boolean)
* getStringAttribute(String, Hashtable, String, boolean)
*/
public void setAttribute(String name,
Object value)
{
public void setAttribute(String name, Object value) {
if (this.ignoreCase) {
name = name.toUpperCase();
}
Expand All @@ -567,9 +558,7 @@ public void setAttribute(String name,
*
* @deprecated Use {@link #setAttribute(String, Object)} instead.
*/
public void addProperty(String name,
Object value)
{
public void addProperty(String name, Object value) {
this.setAttribute(name, value);
}

Expand Down
48 changes: 0 additions & 48 deletions core/src/main/java/org/jnode/util/AccessControllerUtils.java

This file was deleted.

18 changes: 10 additions & 8 deletions core/src/main/java/org/jnode/util/ByteQueueProcessorThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,27 @@

package org.jnode.util;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.lang.System.Logger.Level;
import java.lang.System.Logger;


/**
* @author Ewout Prangsma ([email protected])
*/
public class ByteQueueProcessorThread extends Thread {

private static final Logger bootlog = LogManager.getLogger("bootlog");
private static final Logger bootlog = System.getLogger("bootlog");

/**
* The queue i'm processing
*/
private final ByteQueue queue;

/**
* The actual processor
*/
private final ByteQueueProcessor processor;

private boolean stop;

/**
Expand Down Expand Up @@ -76,19 +79,19 @@ public void stopProcessor() {
/**
* Handle an exception thrown during the processing of the object.
*
* @param ex
* @param ex exception
*/
protected void handleException(Exception ex) {
bootlog.error("Exception in ByteQueueProcessor: " + getName(), ex);
bootlog.log(Level.ERROR, "Exception in ByteQueueProcessor: " + getName(), ex);
}

/**
* Handle an exception thrown during the processing of the object.
*
* @param ex
* @param ex exception
*/
protected void handleError(Error ex) {
bootlog.error("Error in ByteQueueProcessor: " + getName(), ex);
bootlog.log(Level.ERROR, "Error in ByteQueueProcessor: " + getName(), ex);
}

/**
Expand Down Expand Up @@ -117,5 +120,4 @@ public void run() {
public ByteQueue getQueue() {
return queue;
}

}
107 changes: 49 additions & 58 deletions core/src/main/java/org/jnode/util/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,24 @@
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;

import org.apache.logging.log4j.LogManager;
import static java.lang.System.getLogger;


/**
* Common utility code for higher-level operations on IO streams. Notwithstanding the
* nominal access for the class and its methods, user (command) code should avoid using
* this class directly. You should program against the
* {@link org.jnode.shell.io.CommandIO} API instead.
* this class directly.
*
* @author [email protected]
*/
public class IOUtils {

private static final Logger log = getLogger(IOUtils.class.getName());

// FIXME ... these utils (in some cases) attempt to access non-public fields
// of various stream classes in order to figure out what the underlying stream
// is. Currently, we have to explicitly grant the calling application permissions
Expand Down Expand Up @@ -121,71 +124,59 @@ public static Closeable findBaseStream(Closeable stream) {
}

private static InputStream findInputStream(final FilterInputStream inputStream) {
PrivilegedAction<InputStream> pa = () -> {
try {
Class<FilterInputStream> cls = FilterInputStream.class;
Field field = cls.getDeclaredField("in");
field.setAccessible(true);
Object in = field.get(inputStream);
field.setAccessible(false);
return (InputStream) in;
} catch (Exception ex) {
LogManager.getLogger(IOUtils.class).error("Cannot extract the 'in' field", ex);
return null;
}
};
return AccessController.doPrivileged(pa);
try {
Class<FilterInputStream> cls = FilterInputStream.class;
Field field = cls.getDeclaredField("in");
field.setAccessible(true);
Object in = field.get(inputStream);
field.setAccessible(false);
return (InputStream) in;
} catch (Exception ex) {
log.log(Level.ERROR, "Cannot extract the 'in' field", ex);
return null;
}
}

private static OutputStream findOutputStream(final FilterOutputStream outputStream) {
PrivilegedAction<OutputStream> pa = () -> {
try {
Class<FilterOutputStream> cls = FilterOutputStream.class;
Field field = cls.getDeclaredField("out");
field.setAccessible(true);
Object out = field.get(outputStream);
return (OutputStream) out;
} catch (Exception ex) {
LogManager.getLogger(IOUtils.class).error("Cannot extract the 'out' field", ex);
return null;
}
};
return AccessController.doPrivileged(pa);
try {
Class<FilterOutputStream> cls = FilterOutputStream.class;
Field field = cls.getDeclaredField("out");
field.setAccessible(true);
Object out = field.get(outputStream);
return (OutputStream) out;
} catch (Exception ex) {
log.log(Level.ERROR, "Cannot extract the 'out' field", ex);
return null;
}
}

private static OutputStream findOutputStream(final OutputStreamWriter writer) {
// This implementation is based on the knowledge that an OutputStreamWriter
// uses the underlying OutputStream as its 'lock' object.
PrivilegedAction<OutputStream> pa = () -> {
try {
Class<Writer> cls = Writer.class;
Field field = cls.getDeclaredField("lock");
field.setAccessible(true);
Object lock = field.get(writer);
return (OutputStream) lock;
} catch (Exception ex) {
LogManager.getLogger(IOUtils.class).error("Cannot extract the 'lock' field", ex);
return null;
}
};
return AccessController.doPrivileged(pa);
try {
Class<Writer> cls = Writer.class;
Field field = cls.getDeclaredField("lock");
field.setAccessible(true);
Object lock = field.get(writer);
return (OutputStream) lock;
} catch (Exception ex) {
log.log(Level.ERROR, "Cannot extract the 'lock' field", ex);
return null;
}
}

private static InputStream findInputStream(final InputStreamReader reader) {
// This implementation is based on the knowledge that an InputStreamReader
// uses the underlying InputStream as its 'lock' object.
PrivilegedAction<InputStream> pa = () -> {
try {
Class<Reader> cls = Reader.class;
Field field = cls.getDeclaredField("lock");
field.setAccessible(true);
Object lock = field.get(reader);
return (InputStream) lock;
} catch (Exception ex) {
LogManager.getLogger(IOUtils.class).error("Cannot extract the 'lock' field", ex);
return null;
}
};
return AccessController.doPrivileged(pa);
try {
Class<Reader> cls = Reader.class;
Field field = cls.getDeclaredField("lock");
field.setAccessible(true);
Object lock = field.get(reader);
return (InputStream) lock;
} catch (Exception ex) {
log.log(Level.ERROR, "Cannot extract the 'lock' field", ex);
return null;
}
}
}
10 changes: 5 additions & 5 deletions core/src/main/java/org/jnode/util/QueueProcessorThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

package org.jnode.util;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.lang.System.Logger.Level;
import java.lang.System.Logger;

/**
* @author epr
*/
public class QueueProcessorThread<T> extends Thread {

private static final Logger bootlog = LogManager.getLogger("bootlog");
private static final Logger bootlog = System.getLogger("bootlog");

/**
* The queue i'm processing
Expand Down Expand Up @@ -83,7 +83,7 @@ public void stopProcessor() {
* @param ex
*/
protected void handleException(Exception ex) {
bootlog.error("Exception in QueueProcessor: " + getName(), ex);
bootlog.log(Level.ERROR, "Exception in QueueProcessor: " + getName(), ex);
}

/**
Expand All @@ -92,7 +92,7 @@ protected void handleException(Exception ex) {
* @param ex
*/
protected void handleError(Error ex) {
bootlog.error("Error in QueueProcessor: " + getName(), ex);
bootlog.log(Level.ERROR, "Error in QueueProcessor: " + getName(), ex);
}

/**
Expand Down
Loading

0 comments on commit f89c146

Please sign in to comment.