forked from I2P_Developers/i2p.i2p
JRobin: Move DeallocationHelper logging from wrapper log to router log
Fix redundant cast
This commit is contained in:
@ -13,6 +13,9 @@
|
|||||||
cache="../../../build"
|
cache="../../../build"
|
||||||
srcdir="./src"
|
srcdir="./src"
|
||||||
destdir="./build/obj" >
|
destdir="./build/obj" >
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="../../../core/java/build/i2p.jar" />
|
||||||
|
</classpath>
|
||||||
</depend>
|
</depend>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@ -32,6 +35,9 @@
|
|||||||
includeAntRuntime="false"
|
includeAntRuntime="false"
|
||||||
includes="**/*.java" >
|
includes="**/*.java" >
|
||||||
<compilerarg line="${javac.compilerargs}" />
|
<compilerarg line="${javac.compilerargs}" />
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="../../../core/java/build/i2p.jar" />
|
||||||
|
</classpath>
|
||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@ -54,6 +60,7 @@
|
|||||||
<property name="workspace.changes.tr" value="" />
|
<property name="workspace.changes.tr" value="" />
|
||||||
<jar destfile="./build/jrobin.jar" basedir="./build/obj" includes="**/*.class">
|
<jar destfile="./build/jrobin.jar" basedir="./build/obj" includes="**/*.class">
|
||||||
<manifest>
|
<manifest>
|
||||||
|
<attribute name="Class-Path" value="i2p.jar" />
|
||||||
<attribute name="Implementation-Version" value="1.6.0-1" />
|
<attribute name="Implementation-Version" value="1.6.0-1" />
|
||||||
<attribute name="Built-By" value="${build.built-by}" />
|
<attribute name="Built-By" value="${build.built-by}" />
|
||||||
<attribute name="Build-Date" value="${build.timestamp}" />
|
<attribute name="Build-Date" value="${build.timestamp}" />
|
||||||
|
@ -31,8 +31,10 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import net.i2p.I2PAppContext;
|
||||||
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to deallocate memory on the native heap allocated during the creation
|
* Helper to deallocate memory on the native heap allocated during the creation
|
||||||
@ -56,12 +58,16 @@ import java.util.logging.Logger;
|
|||||||
*/
|
*/
|
||||||
public class DeallocationHelper {
|
public class DeallocationHelper {
|
||||||
|
|
||||||
|
private final Log logger = I2PAppContext.getGlobalContext().logManager().getLog(DeallocationHelper.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tool responsible for releasing the native memory of a deallocatable byte
|
* tool responsible for releasing the native memory of a deallocatable byte
|
||||||
* buffer
|
* buffer
|
||||||
*/
|
*/
|
||||||
public static abstract class Deallocator {
|
public static abstract class Deallocator {
|
||||||
|
|
||||||
|
protected final Log logger = I2PAppContext.getGlobalContext().logManager().getLog(DeallocationHelper.class);
|
||||||
|
|
||||||
public Deallocator() {
|
public Deallocator() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@ -101,7 +107,7 @@ public class DeallocationHelper {
|
|||||||
cleanerCleanMethod = cleanerClass.getDeclaredMethod("clean");
|
cleanerCleanMethod = cleanerClass.getDeclaredMethod("clean");
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||||
logger.log(Level.WARNING,
|
logger.warn(
|
||||||
"The initialization of the deallocator for Oracle Java, Sun Java and OpenJDK has failed", e);
|
"The initialization of the deallocator for Oracle Java, Sun Java and OpenJDK has failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,7 +128,7 @@ public class DeallocationHelper {
|
|||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
logger.log(Level.WARNING, "The deallocation of a direct NIO buffer has failed", e);
|
logger.warn("The deallocation of a direct NIO buffer has failed", e);
|
||||||
} finally {
|
} finally {
|
||||||
directByteBufferCleanerMethod.setAccessible(directByteBufferCleanerMethodWasAccessible);
|
directByteBufferCleanerMethod.setAccessible(directByteBufferCleanerMethodWasAccessible);
|
||||||
cleanerCleanMethod.setAccessible(cleanerCleanMethodWasAccessible);
|
cleanerCleanMethod.setAccessible(cleanerCleanMethodWasAccessible);
|
||||||
@ -142,7 +148,7 @@ public class DeallocationHelper {
|
|||||||
final Class<?> directByteBufferClass = Class.forName("java.nio.DirectByteBuffer");
|
final Class<?> directByteBufferClass = Class.forName("java.nio.DirectByteBuffer");
|
||||||
directByteBufferFreeMethod = directByteBufferClass.getDeclaredMethod("free");
|
directByteBufferFreeMethod = directByteBufferClass.getDeclaredMethod("free");
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||||
logger.log(Level.WARNING, "The initialization of the deallocator for Android has failed", e);
|
logger.warn("The initialization of the deallocator for Android has failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +162,7 @@ public class DeallocationHelper {
|
|||||||
directByteBufferFreeMethod.invoke(directByteBuffer);
|
directByteBufferFreeMethod.invoke(directByteBuffer);
|
||||||
success = true;
|
success = true;
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
logger.log(Level.WARNING, "The deallocation of a direct NIO buffer has failed", e);
|
logger.warn("The deallocation of a direct NIO buffer has failed", e);
|
||||||
} finally {
|
} finally {
|
||||||
directByteBufferFreeMethod.setAccessible(directByteBufferFreeMethodWasAccessible);
|
directByteBufferFreeMethod.setAccessible(directByteBufferFreeMethodWasAccessible);
|
||||||
}
|
}
|
||||||
@ -180,7 +186,7 @@ public class DeallocationHelper {
|
|||||||
gnuClasspathPointerClass);
|
gnuClasspathPointerClass);
|
||||||
bufferAddressField = Buffer.class.getDeclaredField("address");
|
bufferAddressField = Buffer.class.getDeclaredField("address");
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException | NoSuchFieldException e) {
|
} catch (ClassNotFoundException | NoSuchMethodException | NoSuchFieldException e) {
|
||||||
logger.log(Level.WARNING, "The initialization of the deallocator for GNU Classpath has failed", e);
|
logger.warn("The initialization of the deallocator for GNU Classpath has failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +205,7 @@ public class DeallocationHelper {
|
|||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
logger.log(Level.WARNING, "The deallocation of a direct NIO buffer has failed", e);
|
logger.warn("The deallocation of a direct NIO buffer has failed", e);
|
||||||
} finally {
|
} finally {
|
||||||
bufferAddressField.setAccessible(bufferAddressFieldWasAccessible);
|
bufferAddressField.setAccessible(bufferAddressFieldWasAccessible);
|
||||||
vmDirectByteBufferFreeMethod.setAccessible(vmDirectByteBufferFreeMethodWasAccessible);
|
vmDirectByteBufferFreeMethod.setAccessible(vmDirectByteBufferFreeMethodWasAccessible);
|
||||||
@ -219,7 +225,7 @@ public class DeallocationHelper {
|
|||||||
final Class<?> directByteBufferClass = Class.forName("java.nio.DirectByteBuffer");
|
final Class<?> directByteBufferClass = Class.forName("java.nio.DirectByteBuffer");
|
||||||
directByteBufferFreeMethod = directByteBufferClass.getDeclaredMethod("free");
|
directByteBufferFreeMethod = directByteBufferClass.getDeclaredMethod("free");
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||||
logger.log(Level.WARNING, "The initialization of the deallocator for Apache Harmony has failed", e);
|
logger.warn("The initialization of the deallocator for Apache Harmony has failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +239,7 @@ public class DeallocationHelper {
|
|||||||
directByteBufferFreeMethod.invoke(directByteBuffer);
|
directByteBufferFreeMethod.invoke(directByteBuffer);
|
||||||
success = true;
|
success = true;
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
logger.log(Level.WARNING, "The deallocation of a direct NIO buffer has failed", e);
|
logger.warn("The deallocation of a direct NIO buffer has failed", e);
|
||||||
} finally {
|
} finally {
|
||||||
directByteBufferFreeMethod.setAccessible(directByteBufferFreeMethodWasAccessible);
|
directByteBufferFreeMethod.setAccessible(directByteBufferFreeMethodWasAccessible);
|
||||||
}
|
}
|
||||||
@ -242,8 +248,6 @@ public class DeallocationHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(DeallocationHelper.class.getName());
|
|
||||||
|
|
||||||
private Map<Class<?>, Field> attachmentOrByteBufferFieldMap;
|
private Map<Class<?>, Field> attachmentOrByteBufferFieldMap;
|
||||||
|
|
||||||
private Set<Class<?>> deallocatableBufferClassSet;
|
private Set<Class<?>> deallocatableBufferClassSet;
|
||||||
@ -431,7 +435,7 @@ public class DeallocationHelper {
|
|||||||
}
|
}
|
||||||
superClassesMsg = builder.toString();
|
superClassesMsg = builder.toString();
|
||||||
}
|
}
|
||||||
logger.warning("The field " + fieldname + " hasn't been found in the class " + classname
|
logger.warn("The field " + fieldname + " hasn't been found in the class " + classname
|
||||||
+ superClassesMsg);
|
+ superClassesMsg);
|
||||||
} else {// the field has been found, stores it into the map
|
} else {// the field has been found, stores it into the map
|
||||||
attachmentOrByteBufferFieldMap.put(bufferClass, bufferField);
|
attachmentOrByteBufferFieldMap.put(bufferClass, bufferField);
|
||||||
@ -449,7 +453,7 @@ public class DeallocationHelper {
|
|||||||
final String msg = "The class " + classname
|
final String msg = "The class " + classname
|
||||||
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
||||||
+ " Java version: " + javaVersion;
|
+ " Java version: " + javaVersion;
|
||||||
logger.log(Level.WARNING, msg, cnfe);
|
logger.warn(msg, cnfe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if a known implementation has drastically changed or if the current
|
// if a known implementation has drastically changed or if the current
|
||||||
@ -567,7 +571,7 @@ public class DeallocationHelper {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException iae) {
|
} catch (IllegalAccessException iae) {
|
||||||
logger.log(Level.WARNING, "Cannot access the field " + field.getName()
|
logger.warn("Cannot access the field " + field.getName()
|
||||||
+ " of the class " + bufferIntermediaryClass.getName(), iae);
|
+ " of the class " + bufferIntermediaryClass.getName(), iae);
|
||||||
} finally {
|
} finally {
|
||||||
field.setAccessible(fieldWasAccessible);
|
field.setAccessible(fieldWasAccessible);
|
||||||
@ -594,7 +598,7 @@ public class DeallocationHelper {
|
|||||||
final String msg = "The class " + directByteBufferClassName
|
final String msg = "The class " + directByteBufferClassName
|
||||||
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
||||||
+ " Java version: " + javaVersion;
|
+ " Java version: " + javaVersion;
|
||||||
logger.log(Level.WARNING, msg, cnfe);
|
logger.warn(msg, cnfe);
|
||||||
}
|
}
|
||||||
if (directByteBufferClass != null)
|
if (directByteBufferClass != null)
|
||||||
deallocatableBufferClassSet.add(directByteBufferClass);
|
deallocatableBufferClassSet.add(directByteBufferClass);
|
||||||
@ -607,7 +611,7 @@ public class DeallocationHelper {
|
|||||||
final String msg = "The class " + readOnlyDirectByteBufferClassName
|
final String msg = "The class " + readOnlyDirectByteBufferClassName
|
||||||
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
||||||
+ " Java version: " + javaVersion;
|
+ " Java version: " + javaVersion;
|
||||||
logger.log(Level.WARNING, msg, cnfe);
|
logger.warn(msg, cnfe);
|
||||||
}
|
}
|
||||||
if (readOnlyDirectByteBufferClass != null)
|
if (readOnlyDirectByteBufferClass != null)
|
||||||
deallocatableBufferClassSet.add(readOnlyDirectByteBufferClass);
|
deallocatableBufferClassSet.add(readOnlyDirectByteBufferClass);
|
||||||
@ -619,7 +623,7 @@ public class DeallocationHelper {
|
|||||||
final String msg = "The class " + readWriteDirectByteBufferClassName
|
final String msg = "The class " + readWriteDirectByteBufferClassName
|
||||||
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
||||||
+ " Java version: " + javaVersion;
|
+ " Java version: " + javaVersion;
|
||||||
logger.log(Level.WARNING, msg, cnfe);
|
logger.warn(msg, cnfe);
|
||||||
}
|
}
|
||||||
if (readWriteDirectByteBufferClass != null)
|
if (readWriteDirectByteBufferClass != null)
|
||||||
deallocatableBufferClassSet.add(readWriteDirectByteBufferClass);
|
deallocatableBufferClassSet.add(readWriteDirectByteBufferClass);
|
||||||
@ -632,7 +636,7 @@ public class DeallocationHelper {
|
|||||||
final String msg = "The class " + readOnlyDirectByteBufferClassName
|
final String msg = "The class " + readOnlyDirectByteBufferClassName
|
||||||
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
||||||
+ " Java version: " + javaVersion;
|
+ " Java version: " + javaVersion;
|
||||||
logger.log(Level.WARNING, msg, cnfe);
|
logger.warn(msg, cnfe);
|
||||||
}
|
}
|
||||||
if (readOnlyDirectByteBufferClass != null)
|
if (readOnlyDirectByteBufferClass != null)
|
||||||
deallocatableBufferClassSet.add(readOnlyDirectByteBufferClass);
|
deallocatableBufferClassSet.add(readOnlyDirectByteBufferClass);
|
||||||
@ -644,7 +648,7 @@ public class DeallocationHelper {
|
|||||||
final String msg = "The class " + readWriteDirectByteBufferClassName
|
final String msg = "The class " + readWriteDirectByteBufferClassName
|
||||||
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
+ " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
|
||||||
+ " Java version: " + javaVersion;
|
+ " Java version: " + javaVersion;
|
||||||
logger.log(Level.WARNING, msg, cnfe);
|
logger.warn(msg, cnfe);
|
||||||
}
|
}
|
||||||
if (readWriteDirectByteBufferClass != null)
|
if (readWriteDirectByteBufferClass != null)
|
||||||
deallocatableBufferClassSet.add(readWriteDirectByteBufferClass);
|
deallocatableBufferClassSet.add(readWriteDirectByteBufferClass);
|
||||||
@ -730,7 +734,7 @@ public class DeallocationHelper {
|
|||||||
// deallocatable buffer
|
// deallocatable buffer
|
||||||
deallocatableDirectByteBuffer = null;
|
deallocatableDirectByteBuffer = null;
|
||||||
final String bufferClassName = bufferClass.getName();
|
final String bufferClassName = bufferClass.getName();
|
||||||
logger.warning("No deallocatable buffer has been found for an instance of the class "
|
logger.warn("No deallocatable buffer has been found for an instance of the class "
|
||||||
+ bufferClassName + " whereas it is a direct NIO buffer");
|
+ bufferClassName + " whereas it is a direct NIO buffer");
|
||||||
}
|
}
|
||||||
} else {// the passed buffer contains another buffer, looks for a
|
} else {// the passed buffer contains another buffer, looks for a
|
||||||
|
@ -188,7 +188,7 @@ public class RRDFile implements Constants {
|
|||||||
if(this.debug) {
|
if(this.debug) {
|
||||||
System.out.println(value);
|
System.out.println(value);
|
||||||
}
|
}
|
||||||
return (int)value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
String readString(int maxLength) throws IOException, RrdException {
|
String readString(int maxLength) throws IOException, RrdException {
|
||||||
|
@ -400,7 +400,7 @@
|
|||||||
<copy file="core/java/build/i2p.jar" todir="build/" />
|
<copy file="core/java/build/i2p.jar" todir="build/" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="buildJrobin" depends="buildProperties" >
|
<target name="buildJrobin" depends="buildCore" >
|
||||||
<ant dir="apps/jrobin/java/" target="jar" />
|
<ant dir="apps/jrobin/java/" target="jar" />
|
||||||
<copy file="apps/jrobin/java/build/jrobin.jar" todir="build/" />
|
<copy file="apps/jrobin/java/build/jrobin.jar" todir="build/" />
|
||||||
</target>
|
</target>
|
||||||
|
Reference in New Issue
Block a user