[Arakhnę-Dev] [359] * Revert from Java 1.7 to Java 1. 6 to obtain class files that may be used by software written with Java 1.6 |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
- To: dev@xxxxxxxxxxx
- Subject: [Arakhnę-Dev] [359] * Revert from Java 1.7 to Java 1. 6 to obtain class files that may be used by software written with Java 1.6
- From: subversion@xxxxxxxxxxxxx
- Date: Tue, 10 Jul 2012 15:50:42 +0200
Revision: 359
Author: galland
Date: 2012-07-10 15:50:41 +0200 (Tue, 10 Jul 2012)
Log Message:
-----------
* Revert from Java 1.7 to Java 1.6 to obtain class files that may be used by software written with Java 1.6
Modified Paths:
--------------
trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractLogger.java
trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractPrintStreamLogger.java
trunk/arakhneLogger/src/main/java/org/arakhne/logging/LoggingSystem.java
trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractPhantomValueMap.java
trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractReferencedValueMap.java
trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractSoftValueMap.java
trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractWeakValueMap.java
trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/WeakArrayList.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractCollectionTestCase.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractMapTestCase.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractReferencableValueMapTestCase.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractTestCase.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/PhantomValueHashMapTest.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/PhantomValueTreeMapTest.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueHashMapTest.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueTreeMapTest.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueHashMapTest.java
trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueTreeMapTest.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/AbstractOperatingSystemWrapper.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/Android.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ClasspathUtil.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/DynamicURLClassLoader.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/FileSystem.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/LibraryLoader.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/MACNumber.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ReflectionUtil.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ThreadServiceFinder.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/URLHandlerUtil.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/VMCommandLine.java
trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/file/URLConnection.java
trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/ClasspathUtilTest.java
trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/FileSystemTest.java
trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/ResourcesTest.java
trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/file/URLConnectionTest.java
trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/resource/URLConnectionTest.java
trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java
trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java
trunk/maventools/src/main/java/org/arakhne/maven/MultiFileFilter.java
trunk/pom.xml
trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/AbstractReplaceMojo.java
trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/GenerateSourceMojo.java
trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceHtmlMojo.java
trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceResourceMojo.java
Modified: trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractLogger.java
===================================================================
--- trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractLogger.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractLogger.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -176,7 +176,7 @@
@Override
public final void addLoggerEventListener(LoggerEventListener listener) {
if (this.listeners==null) {
- this.listeners = new ArrayList<>();
+ this.listeners = new ArrayList<LoggerEventListener>();
}
this.listeners.add(listener);
}
Modified: trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractPrintStreamLogger.java
===================================================================
--- trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractPrintStreamLogger.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneLogger/src/main/java/org/arakhne/logging/AbstractPrintStreamLogger.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -72,6 +72,7 @@
/** {@InheritDoc}
*/
+ @SuppressWarnings("resource")
@Override
public void log(Object source, LogLevel level, String msg, Throwable exception) {
if (isLoggableFor(level)) {
@@ -87,15 +88,14 @@
buffer.append(": "); //$NON-NLS-1$
buffer.append(msg);
- try (PrintStream ps = level.isAnomalyLevel() ? this.anomalyStream : this.noticeStream) {
- ps.println(buffer.toString());
-
- if (exception!=null) {
- exception.printStackTrace(ps);
- }
-
- fireLoggerEvent(source, level, msg);
+ PrintStream ps = level.isAnomalyLevel() ? this.anomalyStream : this.noticeStream;
+ ps.println(buffer.toString());
+
+ if (exception!=null) {
+ exception.printStackTrace(ps);
}
+
+ fireLoggerEvent(source, level, msg);
}
}
Modified: trunk/arakhneLogger/src/main/java/org/arakhne/logging/LoggingSystem.java
===================================================================
--- trunk/arakhneLogger/src/main/java/org/arakhne/logging/LoggingSystem.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneLogger/src/main/java/org/arakhne/logging/LoggingSystem.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -86,7 +86,7 @@
return singleton;
}
- private final Map<String,Logger> preferedLoggers = new TreeMap<>();
+ private final Map<String,Logger> preferedLoggers = new TreeMap<String,Logger>();
private Logger anonymousLogger = null;
private Class<? extends Logger> preferedLoggerType = null;
@@ -245,7 +245,7 @@
*/
public final void addLoggerEventListener(LoggerEventListener listener) {
if (this.listeners==null) {
- this.listeners = new ArrayList<>();
+ this.listeners = new ArrayList<LoggerEventListener>();
}
this.listeners.add(listener);
}
Modified: trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractPhantomValueMap.java
===================================================================
--- trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractPhantomValueMap.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractPhantomValueMap.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -57,7 +57,7 @@
*/
@Override
protected final ReferencableValue<K,V> makeValue(K k, V v, ReferenceQueue<V> queue) {
- return new PhantomReferencedValue<>(k, v, queue);
+ return new PhantomReferencedValue<K,V>(k, v, queue);
}
}
Modified: trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractReferencedValueMap.java
===================================================================
--- trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractReferencedValueMap.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractReferencedValueMap.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -121,7 +121,7 @@
}
private boolean autoExpurge = false;
- private final ReferenceQueue<V> queue = new ReferenceQueue<>();
+ private final ReferenceQueue<V> queue = new ReferenceQueue<V>();
/** Internal map.
*/
Modified: trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractSoftValueMap.java
===================================================================
--- trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractSoftValueMap.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractSoftValueMap.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -57,7 +57,7 @@
*/
@Override
protected final ReferencableValue<K,V> makeValue(K k, V v, ReferenceQueue<V> queue) {
- return new SoftReferencedValue<>(k, v, queue);
+ return new SoftReferencedValue<K,V>(k, v, queue);
}
}
Modified: trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractWeakValueMap.java
===================================================================
--- trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractWeakValueMap.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/AbstractWeakValueMap.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -57,7 +57,7 @@
*/
@Override
protected final ReferencableValue<K,V> makeValue(K k, V v, ReferenceQueue<V> queue) {
- return new WeakReferencedValue<>(k, v, queue);
+ return new WeakReferencedValue<K,V>(k, v, queue);
}
}
Modified: trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/WeakArrayList.java
===================================================================
--- trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/WeakArrayList.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/main/java/org/arakhne/util/ref/WeakArrayList.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -90,7 +90,7 @@
return (value==NULL_VALUE) ? null : value;
}
- private final transient ReferenceQueue<T> queue = new ReferenceQueue<>();
+ private final transient ReferenceQueue<T> queue = new ReferenceQueue<T>();
private Object[] data;
@@ -167,7 +167,7 @@
* @return the weak reference.
*/
private Reference<T> createRef(T obj) {
- return new WeakReference<>(maskNull(obj), this.queue);
+ return new WeakReference<T>(maskNull(obj), this.queue);
}
/**
@@ -356,7 +356,7 @@
*/
public void addReferenceListener(ReferenceListener listener) {
if (this.listeners==null) {
- this.listeners = new LinkedList<>();
+ this.listeners = new LinkedList<ReferenceListener>();
}
List<ReferenceListener> list = this.listeners;
synchronized(list) {
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractCollectionTestCase.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractCollectionTestCase.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractCollectionTestCase.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -51,13 +51,13 @@
public void setUp() throws Exception {
super.setUp();
int count = this.RANDOM.nextInt(400)+100;
- this.reference = new ArrayList<>(count);
+ this.reference = new ArrayList<OBJ>(count);
for(int idx=0; idx<count; idx++) {
this.reference.add(createContentInstance());
}
count = this.RANDOM.nextInt(5)+5;
- this.unreference = new ArrayList<>(count);
+ this.unreference = new ArrayList<OBJ>(count);
for(int idx=0; idx<count; idx++) {
this.unreference.add(createContentInstance());
}
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractMapTestCase.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractMapTestCase.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractMapTestCase.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -56,13 +56,13 @@
public void setUp() throws Exception {
super.setUp();
int count = this.RANDOM.nextInt(400)+100;
- this.reference = new HashMap<>(count);
+ this.reference = new HashMap<K,V>(count);
for(int idx=0; idx<count; idx++) {
this.reference.put(createKeyInstance("in/"), createValueInstance("in/")); //$NON-NLS-1$//$NON-NLS-2$
}
count = this.RANDOM.nextInt(5)+5;
- this.unreference = new HashMap<>(count);
+ this.unreference = new HashMap<K,V>(count);
for(int idx=0; idx<count; idx++) {
this.unreference.put(createKeyInstance("out/"), createValueInstance("out/")); //$NON-NLS-1$//$NON-NLS-2$
}
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractReferencableValueMapTestCase.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractReferencableValueMapTestCase.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractReferencableValueMapTestCase.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -57,7 +57,7 @@
@Override
public void setUp() throws Exception {
super.setUp();
- this.loosedKeys = new TreeSet<>();
+ this.loosedKeys = new TreeSet<String>();
}
/**
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractTestCase.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractTestCase.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/AbstractTestCase.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -366,7 +366,7 @@
}
private static <T> boolean similars(Collection<T> c1, Collection<T> c2) {
- ArrayList<T> a = new ArrayList<>();
+ ArrayList<T> a = new ArrayList<T>();
a.addAll(c2);
for(T elt : c1) {
if (!a.remove(elt)) {
@@ -664,7 +664,7 @@
protected static <T> T[] extractRandomValues(T[] availableValues) {
Random rnd = new Random();
int count = rnd.nextInt(500);
- ArrayList<T> tab = new ArrayList<>(count);
+ ArrayList<T> tab = new ArrayList<T>(count);
for(int i=0; i<count; i++) {
tab.add(availableValues[rnd.nextInt(availableValues.length)]);
}
@@ -769,7 +769,7 @@
* @param actual
*/
protected static <T> void assertEpsilonEquals(String message, Collection<? extends T> expected, Collection<? extends T> actual) {
- ArrayList<T> l = new ArrayList<>(actual);
+ ArrayList<T> l = new ArrayList<T>(actual);
for(T e : expected) {
if (!l.remove(e)) {
fail((message==null ? "" : (message+": ")) //$NON-NLS-1$//$NON-NLS-2$
@@ -804,7 +804,7 @@
* @param actual
*/
protected static <T> void assertEpsilonEquals(String message, T[] expected, T[] actual) {
- ArrayList<T> l = new ArrayList<>(Arrays.asList(actual));
+ ArrayList<T> l = new ArrayList<T>(Arrays.asList(actual));
for(T e : expected) {
if (!l.remove(e)) {
fail((message==null ? "" : (message+": ")) //$NON-NLS-1$//$NON-NLS-2$
@@ -839,7 +839,7 @@
* @param actual
*/
protected static <T> void assertNotEpsilonEquals(String message, T[] expected, T[] actual) {
- ArrayList<T> l = new ArrayList<>(Arrays.asList(actual));
+ ArrayList<T> l = new ArrayList<T>(Arrays.asList(actual));
for(T e : expected) {
if (!l.remove(e)) return;
}
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/PhantomValueHashMapTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/PhantomValueHashMapTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/PhantomValueHashMapTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -40,7 +40,7 @@
*/
@Override
protected Map<String,String> createMap() {
- return new PhantomValueHashMap<>();
+ return new PhantomValueHashMap<String,String>();
}
}
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/PhantomValueTreeMapTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/PhantomValueTreeMapTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/PhantomValueTreeMapTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -40,7 +40,7 @@
*/
@Override
protected Map<String,String> createMap() {
- return new PhantomValueTreeMap<>();
+ return new PhantomValueTreeMap<String,String>();
}
}
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueHashMapTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueHashMapTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueHashMapTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -40,7 +40,7 @@
*/
@Override
protected Map<String,String> createMap() {
- return new SoftValueHashMap<>();
+ return new SoftValueHashMap<String,String>();
}
}
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueTreeMapTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueTreeMapTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/SoftValueTreeMapTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -40,7 +40,7 @@
*/
@Override
protected Map<String,String> createMap() {
- return new SoftValueTreeMap<>();
+ return new SoftValueTreeMap<String,String>();
}
}
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueHashMapTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueHashMapTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueHashMapTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -40,7 +40,7 @@
*/
@Override
protected Map<String,String> createMap() {
- return new WeakValueHashMap<>();
+ return new WeakValueHashMap<String,String>();
}
}
Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueTreeMapTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueTreeMapTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakValueTreeMapTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -40,7 +40,7 @@
*/
@Override
protected Map<String,String> createMap() {
- return new WeakValueTreeMap<>();
+ return new WeakValueTreeMap<String,String>();
}
}
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/AbstractOperatingSystemWrapper.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/AbstractOperatingSystemWrapper.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/AbstractOperatingSystemWrapper.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -56,7 +56,8 @@
Process p = Runtime.getRuntime().exec(command);
if (p==null) return null;
StringBuilder bStr = new StringBuilder();
- try (InputStream standardOutput = p.getInputStream()) {
+ InputStream standardOutput = p.getInputStream();
+ try {
byte[] buffer = new byte[4086];
int len;
while ((len=standardOutput.read(buffer))>0) {
@@ -65,6 +66,9 @@
p.waitFor();
return bStr.toString();
}
+ finally {
+ standardOutput.close();
+ }
}
catch (Exception e) {
return null;
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/Android.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/Android.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/Android.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -171,7 +171,7 @@
throw new AndroidException("not an Android Context class"); //$NON-NLS-1$
synchronized(Android.class) {
contextResolver = null;
- context = new SoftReference<>(androidContext);
+ context = new SoftReference<Object>(androidContext);
}
}
catch(AssertionError e) {
@@ -218,7 +218,7 @@
if (classLoader instanceof ClassLoader) {
cl = (ClassLoader)classLoader;
synchronized(Android.class) {
- contextClassLoader = new WeakReference<>(cl);
+ contextClassLoader = new WeakReference<ClassLoader>(cl);
}
}
else {
@@ -252,7 +252,7 @@
resolver = getContextResolverMethod.invoke(context);
resolver = resolverType.cast(resolver);
synchronized(Android.class) {
- contextResolver = new WeakReference<>(resolver);
+ contextResolver = new WeakReference<Object>(resolver);
}
}
catch(AssertionError e) {
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ClasspathUtil.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ClasspathUtil.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ClasspathUtil.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -49,7 +49,7 @@
@Deprecated
public static URL[] getStartupClasspath() {
Iterator<URL> iterator = getStartClasspath();
- List<URL> list = new ArrayList<>();
+ List<URL> list = new ArrayList<URL>();
while (iterator.hasNext())
list.add(iterator.next());
URL[] tab = new URL[list.size()];
@@ -75,7 +75,7 @@
@Deprecated
public static URL[] getCurrentClasspath() {
Iterator<URL> iterator = getClasspath();
- List<URL> list = new ArrayList<>();
+ List<URL> list = new ArrayList<URL>();
while (iterator.hasNext())
list.add(iterator.next());
URL[] tab = new URL[list.size()];
@@ -89,7 +89,6 @@
* @return the current classpath, never <code>null</code>.
* @since 6.0
*/
- @SuppressWarnings("resource")
public static Iterator<URL> getClasspath() {
Iterator<URL> iterator = getStartClasspath();
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/DynamicURLClassLoader.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/DynamicURLClassLoader.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/DynamicURLClassLoader.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -139,7 +139,7 @@
* @param urls the URL to be added to the search path of URLs
*/
public void removeURLs(URL... urls) {
- HashSet<URL> set = new HashSet<>();
+ HashSet<URL> set = new HashSet<URL>();
set.addAll(Arrays.asList(this._ucp.getURLs()));
set.removeAll(Arrays.asList(urls));
URL[] tab = new URL[set.size()];
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/FileSystem.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/FileSystem.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/FileSystem.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -1196,7 +1196,7 @@
*/
public static void delete(File file) throws IOException {
if (file!=null) {
- LinkedList<File> candidates = new LinkedList<>();
+ LinkedList<File> candidates = new LinkedList<File>();
candidates.add(file);
File f;
File[] children;
@@ -1302,11 +1302,15 @@
outFile = new File(out, largeBasename(in));
}
- try (
- FileInputStream fis = new FileInputStream(in);
- FileOutputStream fos = new FileOutputStream(outFile)) {
+ FileInputStream fis = new FileInputStream(in);
+ FileOutputStream fos = new FileOutputStream(outFile);
+ try {
copy(fis, (int)in.length(), fos);
}
+ finally {
+ fis.close();
+ fos.close();
+ }
}
/** Copy the first file into the second file.
@@ -1348,13 +1352,16 @@
}
URLConnection connection = in.openConnection();
- try (
- FileOutputStream fos = new FileOutputStream(outFile)) {
+ FileOutputStream fos = new FileOutputStream(outFile);
+ try {
copy(
connection.getInputStream(),
connection.getContentLength(),
fos);
}
+ finally {
+ fos.close();
+ }
}
/** Copy the first file into the second file.
@@ -1372,9 +1379,9 @@
public static void copy(InputStream in, int inSize, FileOutputStream out) throws IOException {
assert(in!=null);
assert(out!=null);
- try (
- ReadableByteChannel inChannel = Channels.newChannel(in);
- FileChannel outChannel = out.getChannel()) {
+ ReadableByteChannel inChannel = Channels.newChannel(in);
+ FileChannel outChannel = out.getChannel();
+ try {
int size = inSize;
// apparently has trouble copying large files on Windows
if (size<0 || OperatingSystem.WIN.isCurrentOS()) {
@@ -1391,6 +1398,10 @@
outChannel.transferFrom(inChannel, 0, size);
}
}
+ finally {
+ inChannel.close();
+ outChannel.close();
+ }
}
/** Replies the user home directory.
@@ -2602,7 +2613,7 @@
if (url!=null) {
String[] pathComponents = url.getPath().split(Pattern.quote(URL_PATH_SEPARATOR));
- List<String> canonicalPath = new LinkedList<>();
+ List<String> canonicalPath = new LinkedList<String>();
for(String component : pathComponents) {
if (!CURRENT_DIRECTORY.equals(component)) {
if (PARENT_DIRECTORY.equals(component)) {
@@ -2683,7 +2694,7 @@
if (input==null) return;
- LinkedList<File> candidates = new LinkedList<>();
+ LinkedList<File> candidates = new LinkedList<File>();
candidates.add(input);
byte[] buffer = new byte[2048];
@@ -2712,7 +2723,8 @@
candidates.addAll(Arrays.asList(file.listFiles()));
}
else if (relativeFile!=null) {
- try (FileInputStream fis = new FileInputStream(file)) {
+ FileInputStream fis = new FileInputStream(file);
+ try {
zipFilename = fileToURL(relativeFile);
ZipEntry zipEntry = new ZipEntry(zipFilename);
zos.putNextEntry(zipEntry);
@@ -2721,6 +2733,9 @@
}
zos.closeEntry();
}
+ finally {
+ fis.close();
+ }
}
}
}
@@ -2758,11 +2773,15 @@
}
else {
outFile.getParentFile().mkdirs();
- try (FileOutputStream fos = new FileOutputStream(outFile)) {
+ FileOutputStream fos = new FileOutputStream(outFile);
+ try {
while ((len=zis.read(buffer))>0) {
fos.write(buffer, 0, len);
}
}
+ finally {
+ fos.close();
+ }
}
zipEntry = zis.getNextEntry();
}
@@ -2781,9 +2800,13 @@
* @since 6.2
*/
public static void zipFile(File input, File output) throws IOException {
- try (FileOutputStream fos = new FileOutputStream(output)) {
+ FileOutputStream fos = new FileOutputStream(output);
+ try {
zipFile(input, fos);
}
+ finally {
+ fos.close();
+ }
}
/**
@@ -2795,9 +2818,13 @@
* @since 6.2
*/
public static void unzipFile(File input, File output) throws IOException {
- try (FileInputStream fis = new FileInputStream(input)) {
+ FileInputStream fis = new FileInputStream(input);
+ try {
unzipFile(fis, output);
}
+ finally {
+ fis.close();
+ }
}
/** Create an empty directory in the default temporary-file directory, using
@@ -2964,7 +2991,7 @@
assert(file!=null);
synchronized(this) {
if (this.filesToDelete==null) {
- this.filesToDelete = new LinkedList<>();
+ this.filesToDelete = new LinkedList<File>();
Runtime.getRuntime().addShutdownHook(this);
}
this.filesToDelete.add(file);
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/LibraryLoader.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/LibraryLoader.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/LibraryLoader.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -224,7 +224,7 @@
* <code>null</code>
* @see java.lang.System#load(java.lang.String)
*/
- public static void load(URL filename) throws IOException {
+ public static void load(URL filename) throws IOException {
// Silently ignore loading query
if (DISABLE) return;
@@ -248,16 +248,20 @@
}
File f = File.createTempFile(prefix,suffix);
- // Copy the library code into the local file
- try (
- FileOutputStream outs = new FileOutputStream(f);
- InputStream ins = filename.openStream()) {
+ // Copy the library code into the local file
+ FileOutputStream outs = new FileOutputStream(f);
+ InputStream ins = filename.openStream();
+ try {
byte[] buffer = new byte[2048];
int lu;
while ((lu=ins.read(buffer))>0) {
outs.write(buffer,0,lu);
}
}
+ finally {
+ ins.close();
+ outs.close();
+ }
// Load the library from the local file
load(f);
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/MACNumber.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/MACNumber.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/MACNumber.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -57,7 +57,7 @@
public static MACNumber[] parse(String addresses) {
if ((addresses==null)||("".equals(addresses))) return new MACNumber[0]; //$NON-NLS-1$
String[] adrs = addresses.split(Pattern.quote(Character.toString(MACNUMBER_SEPARATOR)));
- ArrayList<MACNumber> list = new ArrayList<>();
+ ArrayList<MACNumber> list = new ArrayList<MACNumber>();
for (String adr : adrs) {
list.add(new MACNumber(adr));
}
@@ -76,7 +76,7 @@
public static String[] parseAsString(String addresses) {
if ((addresses==null)||("".equals(addresses))) return new String[0]; //$NON-NLS-1$
String[] adrs = addresses.split(Pattern.quote(Character.toString(MACNUMBER_SEPARATOR)));
- ArrayList<String> list = new ArrayList<>();
+ ArrayList<String> list = new ArrayList<String>();
for (String adr : adrs) {
list.add(new MACNumber(adr).toString());
}
@@ -113,7 +113,7 @@
* @see #getPrimaryAdapter
*/
public static Collection<MACNumber> getAllAdapters() {
- List<MACNumber> av = new ArrayList<>();
+ List<MACNumber> av = new ArrayList<MACNumber>();
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
if (interfaces!=null) {
@@ -149,7 +149,7 @@
* @see #getPrimaryAdapterAddresses
*/
public static Map<InetAddress, MACNumber> getAllMappings() {
- Map<InetAddress,MACNumber> av = new HashMap<>();
+ Map<InetAddress,MACNumber> av = new HashMap<InetAddress,MACNumber>();
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
if (interfaces!=null) {
@@ -223,7 +223,7 @@
try {
byte[] addr = inter.getHardwareAddress();
if (addr!=null) {
- Collection<InetAddress> inetList = new ArrayList<>();
+ Collection<InetAddress> inetList = new ArrayList<InetAddress>();
Enumeration<InetAddress> inets = inter.getInetAddresses();
while (inets.hasMoreElements()) {
inetList.add(inets.nextElement());
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ReflectionUtil.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ReflectionUtil.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ReflectionUtil.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -252,7 +252,7 @@
* @return the list of classes in the package.
*/
public static Collection<Class<?>> getPackageClasses(String packageName) {
- Collection<Class<?>> classes = new ArrayList<>();
+ Collection<Class<?>> classes = new ArrayList<Class<?>>();
String[] entries = System.getProperty("java.class.path").split( //$NON-NLS-1$
Pattern.quote(System.getProperty("path.separator"))); //$NON-NLS-1$
@@ -290,7 +290,8 @@
private static void getPackageClassesFromJar(Collection<Class<?>> classes, String jarFilename, String packageName) {
try {
- try (JarFile jarFile = new JarFile(jarFilename)) {
+ JarFile jarFile = new JarFile(jarFilename);
+ try {
String packagePath = packageName.replace(".", "/"); //$NON-NLS-1$//$NON-NLS-2$
Enumeration<JarEntry> entries = jarFile.entries();
@@ -315,6 +316,9 @@
}
}
}
+ finally {
+ jarFile.close();
+ }
}
catch(IOException _) {
//
@@ -355,7 +359,7 @@
* @return the list of subclasses.
*/
public static <T> Collection<Class<? extends T>> getSubClasses(Class<T> className) {
- Collection<Class<? extends T>> list = new ArrayList<>();
+ Collection<Class<? extends T>> list = new ArrayList<Class<? extends T>>();
getSubClasses(className, true, true, true, list);
return list;
}
@@ -390,7 +394,8 @@
@SuppressWarnings("unchecked")
private static <T> void getSubClassesFromJar(Collection<Class<? extends T>> classes, String jarFilename, Class<T> className, boolean allowAbstract, boolean allowInterface, boolean allowEnum) {
try {
- try (JarFile jarFile = new JarFile(jarFilename)) {
+ JarFile jarFile = new JarFile(jarFilename);
+ try {
String classN = className.getCanonicalName();
if (classN!=null) {
Enumeration<JarEntry> entries = jarFile.entries();
@@ -424,6 +429,9 @@
}
}
}
+ finally {
+ jarFile.close();
+ }
}
catch(IOException _) {
//
@@ -434,7 +442,7 @@
private static <T> void getSubClassesFromFileSystem(Collection<Class<? extends T>> classes, String directory, Class<T> className, boolean allowAbstract, boolean allowInterface, boolean allowEnum) {
String classN = className.getCanonicalName();
if (classN!=null) {
- List<String> directories = new ArrayList<>();
+ List<String> directories = new ArrayList<String>();
directories.add(""); //$NON-NLS-1$
String ldir, entryClassname;
@@ -523,7 +531,7 @@
@SuppressWarnings("unchecked")
public static <T,I> Set<Class<? extends I>> getAllDirectInterfaces(Class<? extends T> lowestType, Class<T> highestType, Class<I> interfaceType) {
assert(lowestType!=null);
- Set<Class<? extends I>> collection = new TreeSet<>(ClassComparator.SINGLETON);
+ Set<Class<? extends I>> collection = new TreeSet<Class<? extends I>>(ClassComparator.SINGLETON);
Class<?> type = lowestType;
boolean cont;
do {
@@ -574,7 +582,7 @@
*/
public static <T> Set<Class<?>> getAllDirectInterfaces(Class<? extends T> lowestType, Class<T> highestType) {
assert(lowestType!=null);
- Set<Class<?>> collection = new TreeSet<>(ClassComparator.SINGLETON);
+ Set<Class<?>> collection = new TreeSet<Class<?>>(ClassComparator.SINGLETON);
Class<?> type = lowestType;
boolean cont;
do {
@@ -600,7 +608,7 @@
*/
public static <T> Collection<Class<? super T>> getSuperClasses(Class<T> className) {
assert(className!=null);
- Collection<Class<? super T>> list = new ArrayList<>();
+ Collection<Class<? super T>> list = new ArrayList<Class<? super T>>();
Class<? super T> type = className.getSuperclass();
while (type!=null && !Object.class.equals(type)) {
list.add(type);
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ThreadServiceFinder.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ThreadServiceFinder.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/ThreadServiceFinder.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -37,7 +37,7 @@
*/
public class ThreadServiceFinder {
- private static final Stack<ThreadServiceProvider> services = new Stack<>();
+ private static final Stack<ThreadServiceProvider> services = new Stack<ThreadServiceProvider>();
static {
// Add the default provider
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/URLHandlerUtil.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/URLHandlerUtil.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/URLHandlerUtil.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -39,7 +39,7 @@
private static final String HANDLER_PACKAGES = "java.protocol.handler.pkgs"; //$NON-NLS-1$
private static void install(String... packageNames) {
- List<String> array = new LinkedList<>();
+ List<String> array = new LinkedList<String>();
String str = System.getProperty(HANDLER_PACKAGES);
if (str!=null && !"".equals(str)) { //$NON-NLS-1$
@@ -66,7 +66,7 @@
}
private static void uninstall(String... packageNames) {
- List<String> array = new LinkedList<>();
+ List<String> array = new LinkedList<String>();
String str = System.getProperty(HANDLER_PACKAGES);
if (str!=null && !"".equals(str)) { //$NON-NLS-1$
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/VMCommandLine.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/VMCommandLine.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/VMCommandLine.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -279,7 +279,7 @@
int osize = commandLineOptions==null ? 0 : commandLineOptions.size();
int psize = commandLineParameters==null ? 0 : commandLineParameters.length;
int tsize = (osize>0 && psize>0) ? 1 : 0;
- List<String> params = new ArrayList<>(osize+tsize);
+ List<String> params = new ArrayList<String>(osize+tsize);
if (osize>0) {
List<Object> values;
String name, prefix, v;
@@ -391,7 +391,7 @@
List<Object> values = options.get(name);
if (values==null) {
- values = new ArrayList<>();
+ values = new ArrayList<Object>();
options.put(name, values);
}
switch(type) {
@@ -517,12 +517,12 @@
public static void splitOptionsAndParameters(String... optionDefinitions) {
if (analyzed) return;
- List<String> params = new ArrayList<>();
- SortedMap<String,List<Object>> options = new TreeMap<>();
+ List<String> params = new ArrayList<String>();
+ SortedMap<String,List<Object>> options = new TreeMap<String,List<Object>>();
String opt;
// Analyze definitions
- Map<String,OptionType> defs = new TreeMap<>();
+ Map<String,OptionType> defs = new TreeMap<String,OptionType>();
for (String def : optionDefinitions) {
if (def.endsWith("!")) { //$NON-NLS-1$
opt = def.substring(0, def.length()-1);
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/file/URLConnection.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/file/URLConnection.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/main/java/org/arakhne/vmutil/file/URLConnection.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -149,7 +149,7 @@
catch(IOException e) {
throw new IllegalStateException(e);
}
- Map<String, List<String>> flds = new HashMap<>();
+ Map<String, List<String>> flds = new HashMap<String,List<String>>();
flds.put("content-type", singletonList(this.contentType)); //$NON-NLS-1$
flds.put("content-length", singletonList(Long.toString(this.file.length()))); //$NON-NLS-1$
flds.put("last-modified", singletonList(Long.toString(this.file.lastModified()))); //$NON-NLS-1$
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/ClasspathUtilTest.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/ClasspathUtilTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/ClasspathUtilTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -78,7 +78,7 @@
String[] paths = System.getProperty("java.class.path").split( //$NON-NLS-1$
Pattern.quote(File.pathSeparator));
- List<String> list = new ArrayList<>(Arrays.asList(paths));
+ List<String> list = new ArrayList<String>(Arrays.asList(paths));
while (urls.hasNext()) {
URL u2 = urls.next();
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/FileSystemTest.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/FileSystemTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/FileSystemTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -1599,7 +1599,8 @@
createZip(testArchive);
- try (ZipFile zipFile = new ZipFile(testArchive)) {
+ ZipFile zipFile = new ZipFile(testArchive);
+ try {
ZipEntry zipEntry = zipFile.getEntry("test.txt"); //$NON-NLS-1$
assertNotNull(zipEntry);
@@ -1613,6 +1614,9 @@
assertNotNull(zipEntry);
assertEquals("TEST1: FOR UNIT TEST ONLY", readInputStream(zipFile.getInputStream(zipEntry))); //$NON-NLS-1$
}
+ finally {
+ zipFile.close();
+ }
}
/**
@@ -1635,21 +1639,33 @@
String txt;
File file = new File(testDir, "test.txt"); //$NON-NLS-1$
- try (FileInputStream fis = new FileInputStream(file)) {
+ FileInputStream fis = new FileInputStream(file);
+ try {
txt = readInputStream(fis);
}
+ finally {
+ fis.close();
+ }
assertEquals("TEST1: FOR UNIT TEST ONLY", txt); //$NON-NLS-1$
file = new File(testDir, "test2.txt"); //$NON-NLS-1$
- try (FileInputStream fis = new FileInputStream(file)) {
+ fis = new FileInputStream(file);
+ try {
txt = readInputStream(fis);
}
+ finally {
+ fis.close();
+ }
assertEquals("TEST2: FOR UNIT TEST ONLY", txt); //$NON-NLS-1$
file = new File(subDir, "test.txt"); //$NON-NLS-1$
- try (FileInputStream fis = new FileInputStream(file)) {
+ fis = new FileInputStream(file);
+ try {
txt = readInputStream(fis);
}
+ finally {
+ fis.close();
+ }
assertEquals("TEST1: FOR UNIT TEST ONLY", txt); //$NON-NLS-1$
}
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/ResourcesTest.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/ResourcesTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/ResourcesTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -34,214 +34,294 @@
*/
public class ResourcesTest extends TestCase {
- /**
- */
- public static void testGetResourceString() {
- assertNull(Resources.getResource(null));
+ /**
+ */
+ public static void testGetResourceString() {
+ assertNull(Resources.getResource(null));
- URL u1 = Resources.getResource("/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNotNull(u1);
-
- URL u2 = Resources.getResource("org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNotNull(u2);
-
- assertEquals(u1,u2);
- }
+ URL u1 = Resources.getResource("/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNotNull(u1);
- /**
- */
- public static void testGetResourceClassString() {
- assertNull(Resources.getResource(ResourcesTest.class, null));
-
- URL u1 = Resources.getResource(ResourcesTest.class, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNotNull(u1);
-
- URL u2 = Resources.getResource(ResourcesTest.class, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNotNull(u2);
-
- URL u3 = Resources.getResource(ResourcesTest.class, "test.txt"); //$NON-NLS-1$
- assertNotNull(u3);
+ URL u2 = Resources.getResource("org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNotNull(u2);
- assertEquals(u1,u2);
- assertEquals(u1,u3);
+ assertEquals(u1,u2);
+ }
- assertNull(Resources.getResource((Class<?>)null, null));
-
- u1 = Resources.getResource((Class<?>)null, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNull(u1);
-
- u2 = Resources.getResource((Class<?>)null, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNull(u2);
- }
+ /**
+ */
+ public static void testGetResourceClassString() {
+ assertNull(Resources.getResource(ResourcesTest.class, null));
- /**
- */
- public static void testGetResourcePackageString() {
- ClassLoader l = ResourcesTest.class.getClassLoader();
- Package p = Package.getPackage("org.arakhne.vmutil"); //$NON-NLS-1$
- assertNull(Resources.getResource(ResourcesTest.class, null));
-
- URL u1 = Resources.getResource(l, p, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNull(u1);
-
- URL u2 = Resources.getResource(l, p, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNull(u2);
-
- URL u3 = Resources.getResource(l, p, "test.txt"); //$NON-NLS-1$
- assertNotNull(u3);
+ URL u1 = Resources.getResource(ResourcesTest.class, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNotNull(u1);
- URL u4 = Resources.getResource(l, p, "/test.txt"); //$NON-NLS-1$
- assertNotNull(u4);
-
- assertEquals(u3, u4);
+ URL u2 = Resources.getResource(ResourcesTest.class, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNotNull(u2);
- assertNull(Resources.getResource(l, (Package)null, null));
-
- u1 = Resources.getResource(l, (Package)null, "test.txt"); //$NON-NLS-1$
- assertNull(u1);
-
- u2 = Resources.getResource(l, (Package)null, "/test.txt"); //$NON-NLS-1$
- assertNull(u2);
- }
+ URL u3 = Resources.getResource(ResourcesTest.class, "test.txt"); //$NON-NLS-1$
+ assertNotNull(u3);
- /**
- */
- public static void testGetResourceClassLoaderString() {
- assertNull(Resources.getResource(ResourcesTest.class.getClassLoader(), null));
-
- URL u1 = Resources.getResource(ResourcesTest.class.getClassLoader(), "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNotNull(u1);
-
- URL u2 = Resources.getResource(ResourcesTest.class.getClassLoader(), "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNotNull(u2);
-
- assertEquals(u1,u2);
+ assertEquals(u1,u2);
+ assertEquals(u1,u3);
- assertNull(Resources.getResource((ClassLoader)null, null));
-
- u1 = Resources.getResource((ClassLoader)null, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNotNull(u1);
-
- u2 = Resources.getResource((ClassLoader)null, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
- assertNotNull(u2);
-
- assertEquals(u1,u2);
- }
-
- /**
- * @throws IOException
- */
- public static void testGetResourceAsStreamString() throws IOException {
- assertNull(Resources.getResourceAsStream(null));
+ assertNull(Resources.getResource((Class<?>)null, null));
- try (InputStream is = Resources.getResourceAsStream("/org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
-
- try (InputStream is = Resources.getResourceAsStream("org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
- }
+ u1 = Resources.getResource((Class<?>)null, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNull(u1);
- /**
- * @throws IOException
- */
- public static void testGetResourceAsStreamClassString() throws IOException {
- assertNull(Resources.getResourceAsStream(ResourcesTest.class, null));
+ u2 = Resources.getResource((Class<?>)null, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNull(u2);
+ }
- try (InputStream is = Resources.getResourceAsStream(ResourcesTest.class, "/org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
-
- try (InputStream is = Resources.getResourceAsStream(ResourcesTest.class, "org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
+ /**
+ */
+ public static void testGetResourcePackageString() {
+ ClassLoader l = ResourcesTest.class.getClassLoader();
+ Package p = Package.getPackage("org.arakhne.vmutil"); //$NON-NLS-1$
+ assertNull(Resources.getResource(ResourcesTest.class, null));
- try (InputStream is = Resources.getResourceAsStream(ResourcesTest.class, "/test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
+ URL u1 = Resources.getResource(l, p, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNull(u1);
- try (InputStream is = Resources.getResourceAsStream(ResourcesTest.class, "test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
+ URL u2 = Resources.getResource(l, p, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNull(u2);
- assertNull(Resources.getResourceAsStream((Class<?>)null, null));
+ URL u3 = Resources.getResource(l, p, "test.txt"); //$NON-NLS-1$
+ assertNotNull(u3);
- try (InputStream is = Resources.getResourceAsStream((Class<?>)null, "/org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNull(is);
- }
-
- try (InputStream is = Resources.getResourceAsStream((Class<?>)null, "org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNull(is);
- }
+ URL u4 = Resources.getResource(l, p, "/test.txt"); //$NON-NLS-1$
+ assertNotNull(u4);
- try (InputStream is = Resources.getResourceAsStream((Class<?>)null, "test.txt")) { //$NON-NLS-1$
- assertNull(is);
- }
- }
+ assertEquals(u3, u4);
- /**
- * @throws IOException
- */
- public static void testGetResourceAsStreamPackageString() throws IOException {
- ClassLoader l = ResourcesTest.class.getClassLoader();
- Package p = Package.getPackage("org.arakhne.vmutil"); //$NON-NLS-1$
- assertNull(Resources.getResourceAsStream(ResourcesTest.class, null));
+ assertNull(Resources.getResource(l, (Package)null, null));
- try (InputStream is = Resources.getResourceAsStream(l, p, "/org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNull(is);
- }
-
- try (InputStream is = Resources.getResourceAsStream(l, p, "org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNull(is);
- }
+ u1 = Resources.getResource(l, (Package)null, "test.txt"); //$NON-NLS-1$
+ assertNull(u1);
- try (InputStream is = Resources.getResourceAsStream(l, p, "/test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
+ u2 = Resources.getResource(l, (Package)null, "/test.txt"); //$NON-NLS-1$
+ assertNull(u2);
+ }
- try (InputStream is = Resources.getResourceAsStream(l, p, "test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
-
- assertNull(Resources.getResourceAsStream(l, (Package)null, null));
+ /**
+ */
+ public static void testGetResourceClassLoaderString() {
+ assertNull(Resources.getResource(ResourcesTest.class.getClassLoader(), null));
- try (InputStream is = Resources.getResourceAsStream(l, (Package)null, "/org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNull(is);
- }
-
- try (InputStream is = Resources.getResourceAsStream(l, (Package)null, "org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNull(is);
- }
+ URL u1 = Resources.getResource(ResourcesTest.class.getClassLoader(), "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNotNull(u1);
- try (InputStream is = Resources.getResourceAsStream(l, (Package)null, "test.txt")) { //$NON-NLS-1$
- assertNull(is);
- }
- }
+ URL u2 = Resources.getResource(ResourcesTest.class.getClassLoader(), "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNotNull(u2);
- /**
- * @throws IOException
- */
- public static void testGetResourceAsStreamClassLoaderString() throws IOException {
- assertNull(Resources.getResourceAsStream(ResourcesTest.class.getClassLoader(), null));
-
- try (InputStream is = Resources.getResourceAsStream(ResourcesTest.class.getClassLoader(), "/org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
-
- try (InputStream is = Resources.getResourceAsStream(ResourcesTest.class.getClassLoader(), "org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
+ assertEquals(u1,u2);
- assertNull(Resources.getResourceAsStream((ClassLoader)null, null));
-
- try (InputStream is = Resources.getResourceAsStream((ClassLoader)null, "/org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
-
- try (InputStream is = Resources.getResourceAsStream((ClassLoader)null, "org/arakhne/vmutil/test.txt")) { //$NON-NLS-1$
- assertNotNull(is);
- }
- }
+ assertNull(Resources.getResource((ClassLoader)null, null));
+ u1 = Resources.getResource((ClassLoader)null, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNotNull(u1);
+
+ u2 = Resources.getResource((ClassLoader)null, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ assertNotNull(u2);
+
+ assertEquals(u1,u2);
+ }
+
+ /**
+ * @throws IOException
+ */
+ public static void testGetResourceAsStreamString() throws IOException {
+ assertNull(Resources.getResourceAsStream(null));
+
+ InputStream is = Resources.getResourceAsStream("/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$;
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream("org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+ }
+
+ /**
+ * @throws IOException
+ */
+ public static void testGetResourceAsStreamClassString() throws IOException {
+ assertNull(Resources.getResourceAsStream(ResourcesTest.class, null));
+
+ InputStream is = Resources.getResourceAsStream(ResourcesTest.class, "/org/arakhne/vmutil/test.txt");//$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream(ResourcesTest.class, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream(ResourcesTest.class, "/test.txt"); //$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream(ResourcesTest.class, "test.txt"); //$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ assertNull(Resources.getResourceAsStream((Class<?>)null, null));
+
+ is = Resources.getResourceAsStream((Class<?>)null, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream((Class<?>)null, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream((Class<?>)null, "test.txt"); //$NON-NLS-1$
+ try {
+ assertNull(is);
+ }
+ finally {
+ is.close();
+ }
+ }
+
+ /**
+ * @throws IOException
+ */
+ public static void testGetResourceAsStreamPackageString() throws IOException {
+ ClassLoader l = ResourcesTest.class.getClassLoader();
+ Package p = Package.getPackage("org.arakhne.vmutil"); //$NON-NLS-1$
+ assertNull(Resources.getResourceAsStream(ResourcesTest.class, null));
+
+ InputStream is = Resources.getResourceAsStream(l, p, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream(l, p, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream(l, p, "/test.txt"); //$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream(l, p, "test.txt"); //$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ assertNull(Resources.getResourceAsStream(l, (Package)null, null));
+
+ is = Resources.getResourceAsStream(l, (Package)null, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream(l, (Package)null, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream(l, (Package)null, "test.txt"); //$NON-NLS-1$
+ try {
+ assertNull(is);
+ }
+ finally {
+ is.close();
+ }
+ }
+
+ /**
+ * @throws IOException
+ */
+ public static void testGetResourceAsStreamClassLoaderString() throws IOException {
+ assertNull(Resources.getResourceAsStream(ResourcesTest.class.getClassLoader(), null));
+
+ InputStream is = Resources.getResourceAsStream(ResourcesTest.class.getClassLoader(), "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream(ResourcesTest.class.getClassLoader(), "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ assertNull(Resources.getResourceAsStream((ClassLoader)null, null));
+
+ is = Resources.getResourceAsStream((ClassLoader)null, "/org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+
+ is = Resources.getResourceAsStream((ClassLoader)null, "org/arakhne/vmutil/test.txt"); //$NON-NLS-1$
+ try {
+ assertNotNull(is);
+ }
+ finally {
+ is.close();
+ }
+ }
+
}
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/file/URLConnectionTest.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/file/URLConnectionTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/file/URLConnectionTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -115,11 +115,15 @@
*/
public void testGetInputStream() throws IOException {
String line;
- try (
- InputStream is = this.connection.getInputStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
+ InputStream is = this.connection.getInputStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ try {
line = br.readLine();
}
+ finally {
+ br.close();
+ is.close();
+ }
assertEquals("TEST1: FOR UNIT TEST ONLY", line); //$NON-NLS-1$
}
@@ -133,19 +137,28 @@
URLConnection con = new URLConnection(tmpFile.toURI().toURL());
con.setDoOutput(true);
- try (
- OutputStream os = con.getOutputStream();
- OutputStreamWriter osw = new OutputStreamWriter(os);
- BufferedWriter bw = new BufferedWriter(osw)) {
+ OutputStream os = con.getOutputStream();
+ OutputStreamWriter osw = new OutputStreamWriter(os);
+ BufferedWriter bw = new BufferedWriter(osw);
+ try {
bw.write("HELLO WORLD!"); //$NON-NLS-1$
}
+ finally {
+ bw.close();
+ osw.close();
+ os.close();
+ }
assertEquals(12, tmpFile.length());
String line;
- try (BufferedReader br = new BufferedReader(new FileReader(tmpFile))) {
+ BufferedReader br = new BufferedReader(new FileReader(tmpFile));
+ try {
line = br.readLine();
}
+ finally {
+ br.close();
+ }
assertEquals("HELLO WORLD!", line); //$NON-NLS-1$
}
Modified: trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/resource/URLConnectionTest.java
===================================================================
--- trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/resource/URLConnectionTest.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/arakhneVmutils/arakhneVmutils-java/src/test/java/org/arakhne/vmutil/resource/URLConnectionTest.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -68,11 +68,15 @@
*/
public void testGetInputStream() throws IOException {
String line;
- try (
- InputStream is = this.connection.getInputStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
+ InputStream is = this.connection.getInputStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ try {
line = br.readLine();
}
+ finally {
+ br.close();
+ is.close();
+ }
assertEquals("TEST1: FOR UNIT TEST ONLY", line); //$NON-NLS-1$
}
Modified: trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java
===================================================================
--- trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/license-installer/src/main/java/org/arakhne/maven/plugins/licenseinstaller/InstallLicenseMojo.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -206,13 +206,13 @@
licenseDirectory.mkdirs();
- Set<License> coreInstalled = new HashSet<>();
+ Set<License> coreInstalled = new HashSet<License>();
License lic;
URL resource;
String filename;
File licFile;
- Map<String, License> includedLicenses = new HashMap<>();
+ Map<String, License> includedLicenses = new HashMap<String,License>();
Pattern re = Pattern.compile("^([^:]+):(.+)$"); //$NON-NLS-1$
if (this.thirdPartyLicenses != null) {
for (String tpl : this.thirdPartyLicenses) {
@@ -326,9 +326,13 @@
this.name, this.copyrightDates, this.copyrighters, fullLicenseText.toString(), addParts.toString());
File noticeFile = new File(metainfDirectory, filename);
- try (FileWriter fileWriter = new FileWriter(noticeFile)) {
+ FileWriter fileWriter = new FileWriter(noticeFile);
+ try {
fileWriter.write(noticeText);
}
+ finally {
+ fileWriter.close();
+ }
// ----------------------------------------------------
// AUTHORS
@@ -364,10 +368,15 @@
}
File authorFile = new File(metainfDirectory, filename);
- try (FileWriter fileWriter = new FileWriter(authorFile)) {
+ fileWriter = new FileWriter(authorFile);
+ try {
fileWriter.write(authorsText.toString());
}
- } catch (IOException e) {
+ finally {
+ fileWriter.close();
+ }
+ }
+ catch (IOException e) {
throw new RuntimeException(e);
}
Modified: trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -194,7 +194,7 @@
debug(in.toString()+"->"+out.toString()); //$NON-NLS-1$
debug("Ignore hidden files: "+skipHiddenFiles); //$NON-NLS-1$
out.mkdirs();
- LinkedList<File> candidates = new LinkedList<>();
+ LinkedList<File> candidates = new LinkedList<File>();
candidates.add(in);
File f, targetFile;
File[] children;
@@ -238,7 +238,7 @@
public final void dirRemove(File dir) throws IOException {
if (dir!=null) {
debug("Deleting tree: "+dir.toString()); //$NON-NLS-1$
- LinkedList<File> candidates = new LinkedList<>();
+ LinkedList<File> candidates = new LinkedList<File>();
candidates.add(dir);
File f;
File[] children;
@@ -285,13 +285,19 @@
assert (in != null);
assert (out != null);
debug("Copying file: "+in.toString()+" into "+out.toString()); //$NON-NLS-1$ //$NON-NLS-2$
- try (
- FileInputStream fis = new FileInputStream(in);
- FileChannel inChannel = fis.getChannel();
- FileOutputStream fos = new FileOutputStream(out);
- FileChannel outChannel = fos.getChannel()) {
+ FileInputStream fis = new FileInputStream(in);
+ FileChannel inChannel = fis.getChannel();
+ FileOutputStream fos = new FileOutputStream(out);
+ FileChannel outChannel = fos.getChannel();
+ try {
inChannel.transferTo(0, inChannel.size(), outChannel);
}
+ finally {
+ outChannel.close();
+ fos.close();
+ inChannel.close();
+ fis.close();
+ }
}
/**
@@ -303,15 +309,19 @@
*/
public static final void fileCopy(URL in, File out) throws IOException {
assert (in != null);
- try (
- InputStream inStream = in.openStream();
- OutputStream outStream = new FileOutputStream(out)) {
+ InputStream inStream = in.openStream();
+ OutputStream outStream = new FileOutputStream(out);
+ try {
byte[] buf = new byte[4096];
int len;
while ((len = inStream.read(buf)) > 0) {
outStream.write(buf, 0, len);
}
}
+ finally {
+ outStream.close();
+ inStream.close();
+ }
}
/**
@@ -359,12 +369,12 @@
/**
* Map the directory of pom.xml files to the definition of the corresponding maven module.
*/
- private final Map<File, ExtendedArtifact> localArtifactDescriptions = new TreeMap<>();
+ private final Map<File, ExtendedArtifact> localArtifactDescriptions = new TreeMap<File,ExtendedArtifact>();
/**
* Map the artifact id to the definition of the corresponding maven module.
*/
- private final Map<String, ExtendedArtifact> remoteArtifactDescriptions = new TreeMap<>();
+ private final Map<String, ExtendedArtifact> remoteArtifactDescriptions = new TreeMap<String,ExtendedArtifact>();
/**
* Manager of the SVN repository.
@@ -379,7 +389,7 @@
/**
*/
public AbstractArakhneMojo() {
- List<Charset> availableCharsets = new ArrayList<>();
+ List<Charset> availableCharsets = new ArrayList<Charset>();
// New Mac OS and Linux OS
addCharset(availableCharsets, PREFERRED_CHARSET_UNIX);
@@ -595,7 +605,7 @@
* @return the list of files.
*/
public final Collection<File> findFiles(File directory, FileFilter filter) {
- Collection<File> files = new ArrayList<>();
+ Collection<File> files = new ArrayList<File>();
findFiles(directory, filter, files);
return files;
}
@@ -613,7 +623,7 @@
public final synchronized void findFiles(File directory, FileFilter filter, Collection<? super File> fileOut) {
if (directory != null && filter != null) {
File candidate;
- List<File> candidates = new ArrayList<>();
+ List<File> candidates = new ArrayList<File>();
String relativePath = removePathPrefix(getBaseDirectory(), directory);
@@ -675,7 +685,7 @@
FindFileListener listener) {
if (directory != null && filter != null) {
File candidate;
- List<File> candidates = new ArrayList<>();
+ List<File> candidates = new ArrayList<File>();
String relativePath = removePathPrefix(getBaseDirectory(), directory);
@@ -841,45 +851,56 @@
return null;
MavenXpp3Reader pomReader = new MavenXpp3Reader();
- try (FileReader fr = new FileReader(pomFile)) {
- Model model = pomReader.read(fr);
- groupId = model.getGroupId();
- artifactId = model.getArtifactId();
- name = model.getName();
- version = model.getVersion();
- url = model.getUrl();
- organization = model.getOrganization();
- scm = model.getScm();
-
- developers = model.getDevelopers();
- contributors = model.getContributors();
- licenses = model.getLicenses();
-
- parent = model.getParent();
- } catch (IOException e) {
+ try {
+ FileReader fr = new FileReader(pomFile);
+ try {
+ Model model = pomReader.read(fr);
+ groupId = model.getGroupId();
+ artifactId = model.getArtifactId();
+ name = model.getName();
+ version = model.getVersion();
+ url = model.getUrl();
+ organization = model.getOrganization();
+ scm = model.getScm();
+
+ developers = model.getDevelopers();
+ contributors = model.getContributors();
+ licenses = model.getLicenses();
+
+ parent = model.getParent();
+ }
+ catch (IOException e) {
+ return null;
+ }
+ catch (XmlPullParserException e) {
+ return null;
+ }
+ finally {
+ fr.close();
+ }
+ }
+ catch (IOException e) {
return null;
- } catch (XmlPullParserException e) {
- return null;
}
if (developers == null) {
- developers = new ArrayList<>();
+ developers = new ArrayList<Developer>();
} else {
- List<Developer> list = new ArrayList<>();
+ List<Developer> list = new ArrayList<Developer>();
list.addAll(developers);
developers = list;
}
if (contributors == null) {
- contributors = new ArrayList<>();
+ contributors = new ArrayList<Contributor>();
} else {
- List<Contributor> list = new ArrayList<>();
+ List<Contributor> list = new ArrayList<Contributor>();
list.addAll(contributors);
contributors = list;
}
if (licenses == null) {
- licenses = new ArrayList<>();
+ licenses = new ArrayList<License>();
} else {
- List<License> list = new ArrayList<>();
+ List<License> list = new ArrayList<License>();
list.addAll(licenses);
licenses = list;
}
@@ -1209,16 +1230,22 @@
private static void detectEncoding(File file, CharsetDecoder decoder) throws IOException, CharacterCodingException {
decoder.onMalformedInput(CodingErrorAction.REPORT);
decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
- try (
- FileInputStream fis = new FileInputStream(file);
- ReadableByteChannel channel = Channels.newChannel(fis);
- Reader reader = Channels.newReader(channel, decoder, -1);
- BufferedReader bReader = new BufferedReader(reader)) {
+ FileInputStream fis = new FileInputStream(file);
+ ReadableByteChannel channel = Channels.newChannel(fis);
+ Reader reader = Channels.newReader(channel, decoder, -1);
+ BufferedReader bReader = new BufferedReader(reader);
+ try {
String line = bReader.readLine();
while (line != null) {
line = bReader.readLine();
}
}
+ finally {
+ bReader.close();
+ reader.close();
+ channel.close();
+ fis.close();
+ }
}
/**
@@ -1231,7 +1258,7 @@
* @see #setPreferredCharsets(Charset...)
*/
public final Charset detectEncoding(File file) {
- Collection<Charset> fittingCharsets = new TreeSet<>();
+ Collection<Charset> fittingCharsets = new TreeSet<Charset>();
for (Charset c : Charset.availableCharsets().values()) {
CharsetDecoder decoder = c.newDecoder();
try {
@@ -1352,8 +1379,8 @@
private final List<ArtifactRepository> remoteRepositiories;
private final boolean isTransitive;
- private List<Dependency> dependencies = new ArrayList<>();
- private Set<String> treated = new TreeSet<>();
+ private List<Dependency> dependencies = new ArrayList<Dependency>();
+ private Set<String> treated = new TreeSet<String>();
private MavenProject next;
/**
Modified: trunk/maventools/src/main/java/org/arakhne/maven/MultiFileFilter.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/MultiFileFilter.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/maventools/src/main/java/org/arakhne/maven/MultiFileFilter.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -35,7 +35,7 @@
*/
public class MultiFileFilter implements FileFilter {
- private final Collection<FileFilter> filters = new ArrayList<>();
+ private final Collection<FileFilter> filters = new ArrayList<FileFilter>();
/**
*/
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/pom.xml 2012-07-10 13:50:41 UTC (rev 359)
@@ -381,8 +381,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.7</source>
- <target>1.7</target>
+ <target>1.6</target>
+ <source>1.6</source>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
Modified: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/AbstractReplaceMojo.java
===================================================================
--- trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/AbstractReplaceMojo.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/AbstractReplaceMojo.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -326,20 +326,20 @@
+ inputFile.getName() + "' with '" //$NON-NLS-1$
+ charset.displayName() + "' encoding"); //$NON-NLS-1$
- try (
- FileInputStream fis = new FileInputStream(inputFile);
- ReadableByteChannel channel = Channels.newChannel(fis)) {
+ FileInputStream fis = new FileInputStream(inputFile);
+ ReadableByteChannel channel = Channels.newChannel(fis);
+ try {
r = Channels.newReader(channel, charset.newDecoder(), -1);
if (r == null) {
r = new FileReader(inputFile);
}
- try (
- BufferedReader br = new BufferedReader(r);
- FileOutputStream fos = new FileOutputStream(outputFile);
- WritableByteChannel wChannel = Channels.newChannel(fos);
- Writer w = Channels.newWriter(wChannel, charset.newEncoder(), -1)) {
+ BufferedReader br = new BufferedReader(r);
+ FileOutputStream fos = new FileOutputStream(outputFile);
+ WritableByteChannel wChannel = Channels.newChannel(fos);
+ Writer w = Channels.newWriter(wChannel, charset.newEncoder(), -1);
+ try {
String line;
int nLine = 1;
@@ -351,7 +351,18 @@
}
w.flush();
}
+ finally {
+ w.close();
+ wChannel.close();
+ fos.close();
+ br.close();
+ }
}
+ finally {
+ if (r!=null) r.close();
+ channel.close();
+ fis.close();
+ }
if (sourceFile == null) {
fileCopy(outputFile, targetFile);
Modified: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/GenerateSourceMojo.java
===================================================================
--- trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/GenerateSourceMojo.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/GenerateSourceMojo.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -93,7 +93,7 @@
clearInternalBuffers();
- Map<File,File> htmlBasedFiles = new TreeMap<>();
+ Map<File,File> htmlBasedFiles = new TreeMap<File,File>();
for(File sourceDir : sourceDirs) {
if ( sourceDir.isDirectory() ) {
Modified: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceHtmlMojo.java
===================================================================
--- trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceHtmlMojo.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceHtmlMojo.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -67,8 +67,7 @@
clearInternalBuffers();
- Collection<File> textBasedFiles = new ArrayList<>();
-
+ Collection<File> textBasedFiles = new ArrayList<File>();
for(File htmlDir : htmlDirs) {
if ( htmlDir.isDirectory() ) {
// Search for .html files
Modified: trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceResourceMojo.java
===================================================================
--- trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceResourceMojo.java 2012-07-09 20:37:14 UTC (rev 358)
+++ trunk/tag-replacer/src/main/java/org/arakhne/maven/plugins/tagreplacer/ReplaceResourceMojo.java 2012-07-10 13:50:41 UTC (rev 359)
@@ -66,7 +66,7 @@
clearInternalBuffers();
- Collection<File> textBasedFiles = new ArrayList<>();
+ Collection<File> textBasedFiles = new ArrayList<File>();
for(File sourceDir : sourceDirs) {
if ( sourceDir.isDirectory() ) {