harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r804884 [1/2] - in /harmony/enhanced/tools/trunk/minijre: ./ conf/ native/ script/ src/org/crazynut/harmony/minjre/ src/org/crazynut/harmony/minjre/anttask/ src/org/crazynut/harmony/minjre/bin/
Date Mon, 17 Aug 2009 07:35:17 GMT
Author: hindessm
Date: Mon Aug 17 07:35:16 2009
New Revision: 804884

URL: http://svn.apache.org/viewvc?rev=804884&view=rev
Log:
Fixing inconsistent line endings.  Adding svn:eol-style property.

Modified:
    harmony/enhanced/tools/trunk/minijre/build.xml   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/conf/harmony.cns   (props changed)
    harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.cpp   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.h   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/native/Main.cpp   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/script/analyze.bat   (props changed)
    harmony/enhanced/tools/trunk/minijre/script/analyze.cmd   (props changed)
    harmony/enhanced/tools/trunk/minijre/script/analyze.sh   (props changed)
    harmony/enhanced/tools/trunk/minijre/script/jregen.bat   (props changed)
    harmony/enhanced/tools/trunk/minijre/script/jregen.cmd   (props changed)
    harmony/enhanced/tools/trunk/minijre/script/jregen.sh   (props changed)
    harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/CNSFileFormatException.java   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/ClassNameSet.java   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/JreGenerator.java   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/StaticDependencyAnalyzer.java   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/AnalyzeDependencyTask.java   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/anttask/GenerateJreTask.java   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/AnalyzeDependency.java   (contents, props changed)
    harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/bin/GenerateJre.java   (contents, props changed)

Modified: harmony/enhanced/tools/trunk/minijre/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/build.xml?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/build.xml (original)
+++ harmony/enhanced/tools/trunk/minijre/build.xml Mon Aug 17 07:35:16 2009
@@ -1,199 +1,199 @@
-<?xml version="1.0"?>
-<project name="MinJre Toolkit" default="dist">
-	
-	<property environment="env" />
-
-	<!-- build properies -->
-	<property name="src.dir" value="src" />
-	<property name="build.dir" value="build" />
-	<property name="lib.dir" value="lib" />
-	<property name="dist.dir" value="dist" />
-	<property name="native.dir" value="native" />
-	<property name="script.dir" value="script" />
-	<property name="conf.dir" value="conf" />
-
-	<!-- user properies -->
-	<property name="jdk.dir" value="${env.JAVA_HOME}" />
+<?xml version="1.0"?>
+<project name="MinJre Toolkit" default="dist">
+	
+	<property environment="env" />
+
+	<!-- build properies -->
+	<property name="src.dir" value="src" />
+	<property name="build.dir" value="build" />
+	<property name="lib.dir" value="lib" />
+	<property name="dist.dir" value="dist" />
+	<property name="native.dir" value="native" />
+	<property name="script.dir" value="script" />
+	<property name="conf.dir" value="conf" />
+
+	<!-- user properies -->
+	<property name="jdk.dir" value="${env.JAVA_HOME}" />
 	<property name="cns.dir" value="cns" />
-
-	<property name="agent.name" value="tracer" />
-	<property name="origin.dir" value="C:/java/harmony-jre" />
-	<property name="target.dir" value="C:/java/harmony-jre-min" />
-
-	<!-- test properies -->
-	<property name="test.dir" value="test" />
-	
-	<!-- os property, used for native compiling -->
-	<condition property="isWindows">    
-		<os family="windows" />   
-    </condition>
-    <condition property="isUnix"> 
-        <os family="unix" />
-    </condition>
-    <condition property="isOther">
-		<and>
-			<os family="dos" />
-			<os family="mac" />
-			<os family="netware" />
-			<os family="os 2" />
-		</and>
-    </condition>
-
-	<!-- check dependencies property, build will fail unless it is true -->
-	<!-- NOT IMPLEMENTED YET! -->
-	<!-- <condition property="all.dependencies.present">
-	</condition> -->
-
-	<!-- test unnecessary property, test will be ignored if it is true -->
-	<!-- NOT IMPLEMENTED YET! -->
-	<!-- <condition property="test.unnecessary">
-	</condition> -->
-
-	<!-- define classpath -->
-	<path id="classpath">
-		<fileset file="${lib.dir}/*.jar" />
-		<pathelement path="${build.dir}" />
-	</path>
-
-	<!-- initialize task -->
+
+	<property name="agent.name" value="tracer" />
+	<property name="origin.dir" value="C:/java/harmony-jre" />
+	<property name="target.dir" value="C:/java/harmony-jre-min" />
+
+	<!-- test properies -->
+	<property name="test.dir" value="test" />
+	
+	<!-- os property, used for native compiling -->
+	<condition property="isWindows">    
+		<os family="windows" />   
+    </condition>
+    <condition property="isUnix"> 
+        <os family="unix" />
+    </condition>
+    <condition property="isOther">
+		<and>
+			<os family="dos" />
+			<os family="mac" />
+			<os family="netware" />
+			<os family="os 2" />
+		</and>
+    </condition>
+
+	<!-- check dependencies property, build will fail unless it is true -->
+	<!-- NOT IMPLEMENTED YET! -->
+	<!-- <condition property="all.dependencies.present">
+	</condition> -->
+
+	<!-- test unnecessary property, test will be ignored if it is true -->
+	<!-- NOT IMPLEMENTED YET! -->
+	<!-- <condition property="test.unnecessary">
+	</condition> -->
+
+	<!-- define classpath -->
+	<path id="classpath">
+		<fileset file="${lib.dir}/*.jar" />
+		<pathelement path="${build.dir}" />
+	</path>
+
+	<!-- initialize task -->
 	<target name="init">
-
-		<!-- <fail message="Missing dependencies. Building fails." unless="all.dependencies.present" /> -->
-	</target>
-
-	<target name="-compile-native-win" if="isWindows">
-		<exec dir="${native.dir}" executable="cl">
-			<arg line="/EHsc" />
-			<arg line="-I${jdk.dir}\include" />
-			<arg line="-I${jdk.dir}\include\win32" />
-			<arg line="-LD" />
-			<arg line="ClassLoadTraceAgent.cpp" />
-			<arg line="Main.cpp" />
-			<arg line="-Fe${agent.name}.dll" />
-		</exec>
-		<delete dir="${native.dir}" excludes="**\*.cpp **\*.h **\*.dll" />
-	</target>
-	
-	<target name="-compile-native-unix" if="isUnix">
-		<exec dir="${native.dir}" executable="g++">
-			<arg line="-I${jdk.dir}/include" />
-			<arg line="-I${jdk.dir}/include/linux" />
-			<arg line="ClassLoadTraceAgent.cpp" />
-			<arg line="Main.cpp" />
-			<arg line="-fPIC" />
-			<arg line="-shared" />
-			<arg line="-o lib${agent.name}.so" />
-		</exec>
-		<delete dir="${native.dir}" excludes="**\*.cpp **\*.h **\*.so" />
-	</target>
-
-	<target name="-compile-native-other" if="isOther">
-		<echo message="Dynamic tracer agent is not supported in this os and will not be included in the distribution." />
-	</target>
-
-	<target name="compile-native" depends="init, -compile-native-win, -compile-native-unix, -compile-native-other" />
-
-	<target name="compile-java" depends="init">
-		<mkdir dir="${build.dir}"/>
-		<javac srcdir="${src.dir}" destdir="${build.dir}" target="1.5">
-			<classpath refid="classpath"/>
-		</javac>
-		<mkdir dir="${build.dir}/org/crazynut/harmony/minjre/conf" />
-		<copy todir="${build.dir}/org/crazynut/harmony/minjre/conf">
-			<fileset file="${conf.dir}/*.cns" />
-		</copy>
-	</target>
-
-	<!-- compile -->
-	<target name="compile" depends="compile-native, compile-java" description="Compile the source files." />
-	
-	<!-- test the command line tool with helloworld -->
-	<target name="test-hello" depends="compile">
-    	<delete dir="${cns.dir}" />
-    	<mkdir dir="${cns.dir}" />
-		<delete dir="${target.dir}" />
-    	<mkdir dir="${target.dir}" />
-		<java classname="org.crazynut.harmony.minjre.bin.AnalyzeDependency">
-			<classpath refid="classpath"/>
-			<arg line="-jrelib=${origin.dir}/lib" />
-			<arg line="-classpath=${test.dir}/hello" />
-			<arg line="-aim=${cns.dir}/static.cns" />
-		</java>
-		<java classname="Hello" fork="true" dir="${test.dir}/hello">
-			<env key="PATH" path="${env.PATH}:${native.dir}" />
+
+		<!-- <fail message="Missing dependencies. Building fails." unless="all.dependencies.present" /> -->
+	</target>
+
+	<target name="-compile-native-win" if="isWindows">
+		<exec dir="${native.dir}" executable="cl">
+			<arg line="/EHsc" />
+			<arg line="-I${jdk.dir}\include" />
+			<arg line="-I${jdk.dir}\include\win32" />
+			<arg line="-LD" />
+			<arg line="ClassLoadTraceAgent.cpp" />
+			<arg line="Main.cpp" />
+			<arg line="-Fe${agent.name}.dll" />
+		</exec>
+		<delete dir="${native.dir}" excludes="**\*.cpp **\*.h **\*.dll" />
+	</target>
+	
+	<target name="-compile-native-unix" if="isUnix">
+		<exec dir="${native.dir}" executable="g++">
+			<arg line="-I${jdk.dir}/include" />
+			<arg line="-I${jdk.dir}/include/linux" />
+			<arg line="ClassLoadTraceAgent.cpp" />
+			<arg line="Main.cpp" />
+			<arg line="-fPIC" />
+			<arg line="-shared" />
+			<arg line="-o lib${agent.name}.so" />
+		</exec>
+		<delete dir="${native.dir}" excludes="**\*.cpp **\*.h **\*.so" />
+	</target>
+
+	<target name="-compile-native-other" if="isOther">
+		<echo message="Dynamic tracer agent is not supported in this os and will not be included in the distribution." />
+	</target>
+
+	<target name="compile-native" depends="init, -compile-native-win, -compile-native-unix, -compile-native-other" />
+
+	<target name="compile-java" depends="init">
+		<mkdir dir="${build.dir}"/>
+		<javac srcdir="${src.dir}" destdir="${build.dir}" target="1.5">
+			<classpath refid="classpath"/>
+		</javac>
+		<mkdir dir="${build.dir}/org/crazynut/harmony/minjre/conf" />
+		<copy todir="${build.dir}/org/crazynut/harmony/minjre/conf">
+			<fileset file="${conf.dir}/*.cns" />
+		</copy>
+	</target>
+
+	<!-- compile -->
+	<target name="compile" depends="compile-native, compile-java" description="Compile the source files." />
+	
+	<!-- test the command line tool with helloworld -->
+	<target name="test-hello" depends="compile">
+    	<delete dir="${cns.dir}" />
+    	<mkdir dir="${cns.dir}" />
+		<delete dir="${target.dir}" />
+    	<mkdir dir="${target.dir}" />
+		<java classname="org.crazynut.harmony.minjre.bin.AnalyzeDependency">
+			<classpath refid="classpath"/>
+			<arg line="-jrelib=${origin.dir}/lib" />
+			<arg line="-classpath=${test.dir}/hello" />
+			<arg line="-aim=${cns.dir}/static.cns" />
+		</java>
+		<java classname="Hello" fork="true" dir="${test.dir}/hello">
+			<env key="PATH" path="${env.PATH}:${native.dir}" />
 			<env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${native.dir}" />
-
-			<jvmarg line="-agentlib:${agent.name}=output=dynamic.cns" />
-		</java>
-		<copy file="${test.dir}/hello/dynamic.cns" toDir="${cns.dir}" />
-		<java classname="org.crazynut.harmony.minjre.bin.GenerateJre">
-			<classpath refid="classpath"/>
-			<arg line="-jre=harmony" />
-			<arg line="-cnspath=${cns.dir}" />
-			<arg line="-origin=${origin.dir}" />
-			<arg line="-target=${target.dir}" />
-		</java>
-    	<exec executable="${target.dir}/bin/java">
-    	    <arg line="-classpath ${test.dir}/hello Hello"/>
-    	</exec>
-	</target>
-
-	<!-- test the ant task with helloworld -->
+
+			<jvmarg line="-agentlib:${agent.name}=output=dynamic.cns" />
+		</java>
+		<copy file="${test.dir}/hello/dynamic.cns" toDir="${cns.dir}" />
+		<java classname="org.crazynut.harmony.minjre.bin.GenerateJre">
+			<classpath refid="classpath"/>
+			<arg line="-jre=harmony" />
+			<arg line="-cnspath=${cns.dir}" />
+			<arg line="-origin=${origin.dir}" />
+			<arg line="-target=${target.dir}" />
+		</java>
+    	<exec executable="${target.dir}/bin/java">
+    	    <arg line="-classpath ${test.dir}/hello Hello"/>
+    	</exec>
+	</target>
+
+	<!-- test the ant task with helloworld -->
 	
 <target name="test-task-hello" depends="compile">
-
-		<taskdef name="analyze" classname="org.crazynut.harmony.minjre.anttask.AnalyzeDependencyTask" classpath="${build.dir};${lib.dir}/bcel-5.2.jar" />
-		<taskdef name="jregen" classname="org.crazynut.harmony.minjre.anttask.GenerateJreTask" classpath="${build.dir}" />
-		<delete dir="${cns.dir}" />
-    	<mkdir dir="${cns.dir}" />
-		<delete dir="${target.dir}" />
-    	<mkdir dir="${target.dir}" />
-    	<analyze jrelib="${origin.dir}/lib" aim="${cns.dir}/static.cns">
-    		<classpath>
-				<pathelement location="${test.dir}/hello"/>
-			</classpath>
-    	</analyze>
-    	<jregen jre="harmony" origin="${origin.dir}" target="${target.dir}">
-    		<cnspath path="${cns.dir}" />
-    	</jregen>
-    	<exec executable="${target.dir}/bin/java">
-    	    <arg line="-classpath ${test.dir}/hello Hello"/>
+
+		<taskdef name="analyze" classname="org.crazynut.harmony.minjre.anttask.AnalyzeDependencyTask" classpath="${build.dir};${lib.dir}/bcel-5.2.jar" />
+		<taskdef name="jregen" classname="org.crazynut.harmony.minjre.anttask.GenerateJreTask" classpath="${build.dir}" />
+		<delete dir="${cns.dir}" />
+    	<mkdir dir="${cns.dir}" />
+		<delete dir="${target.dir}" />
+    	<mkdir dir="${target.dir}" />
+    	<analyze jrelib="${origin.dir}/lib" aim="${cns.dir}/static.cns">
+    		<classpath>
+				<pathelement location="${test.dir}/hello"/>
+			</classpath>
+    	</analyze>
+    	<jregen jre="harmony" origin="${origin.dir}" target="${target.dir}">
+    		<cnspath path="${cns.dir}" />
+    	</jregen>
+    	<exec executable="${target.dir}/bin/java">
+    	    <arg line="-classpath ${test.dir}/hello Hello"/>
     	</exec>
-
-	</target>
 
-
-    <target name="test" depends="test-hello, test-task-hello" />
-	
-	<!-- create the distribution -->
-	<target name="dist" depends="test" description="Create everything for the MinJre Toolkit.">
-		<mkdir dir="${dist.dir}" />
-		<mkdir dir="${dist.dir}/bin" />
-		<copy todir="${dist.dir}/bin">
-			<fileset file="${script.dir}/*.*" />
-		</copy>
-		<mkdir dir="${dist.dir}/lib" />
-		<jar destfile="${dist.dir}/lib/minjre.jar" basedir="${build.dir}" />
-		<copy file="${lib.dir}/bcel-5.2.jar" todir="${dist.dir}/lib" />
-		<mkdir dir="${dist.dir}/agent" />
-		<copy todir="${dist.dir}/agent">
-			<fileset file="${native.dir}/*.so" />
-			<fileset file="${native.dir}/*.dll" />
-		</copy>
-		<mkdir dir="${dist.dir}/doc" />
-		<javadoc destdir="${dist.dir}/doc" author="true" version="true" use="true" windowtitle="MinJre Toolkit API">
-			<packageset dir="${src.dir}" defaultexcludes="yes" />
-			<doctitle><![CDATA[<h1>MinJre Toolkit API</h1>]]></doctitle>
-			<bottom><![CDATA[<i>Auther Daniel Gong.</i>]]></bottom>
-			<tag name="todo" scope="all" description="To do:" />
-		</javadoc>
-	</target>
-	
-	<target name="clean" description="Restore the project directory.">
-		<delete dir="${build.dir}" />
-		<delete dir="${cns.dir}" />
-		<delete dir="${dist.dir}" />
-		<delete dir="${native.dir}" excludes="**\*.cpp **\*.h" />
-	</target>
-
+	</target>
+
+
+    <target name="test" depends="test-hello, test-task-hello" />
+	
+	<!-- create the distribution -->
+	<target name="dist" depends="test" description="Create everything for the MinJre Toolkit.">
+		<mkdir dir="${dist.dir}" />
+		<mkdir dir="${dist.dir}/bin" />
+		<copy todir="${dist.dir}/bin">
+			<fileset file="${script.dir}/*.*" />
+		</copy>
+		<mkdir dir="${dist.dir}/lib" />
+		<jar destfile="${dist.dir}/lib/minjre.jar" basedir="${build.dir}" />
+		<copy file="${lib.dir}/bcel-5.2.jar" todir="${dist.dir}/lib" />
+		<mkdir dir="${dist.dir}/agent" />
+		<copy todir="${dist.dir}/agent">
+			<fileset file="${native.dir}/*.so" />
+			<fileset file="${native.dir}/*.dll" />
+		</copy>
+		<mkdir dir="${dist.dir}/doc" />
+		<javadoc destdir="${dist.dir}/doc" author="true" version="true" use="true" windowtitle="MinJre Toolkit API">
+			<packageset dir="${src.dir}" defaultexcludes="yes" />
+			<doctitle><![CDATA[<h1>MinJre Toolkit API</h1>]]></doctitle>
+			<bottom><![CDATA[<i>Auther Daniel Gong.</i>]]></bottom>
+			<tag name="todo" scope="all" description="To do:" />
+		</javadoc>
+	</target>
+	
+	<target name="clean" description="Restore the project directory.">
+		<delete dir="${build.dir}" />
+		<delete dir="${cns.dir}" />
+		<delete dir="${dist.dir}" />
+		<delete dir="${native.dir}" excludes="**\*.cpp **\*.h" />
+	</target>
+
 </project>

Propchange: harmony/enhanced/tools/trunk/minijre/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/tools/trunk/minijre/conf/harmony.cns
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.cpp?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.cpp (original)
+++ harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.cpp Mon Aug 17 07:35:16 2009
@@ -1,94 +1,94 @@
-#include <string>
-#include <string.h>
-
-#include "ClassLoadTraceAgent.h"
-
-using namespace std;
-
-jvmtiEnv* ClassLoadTraceAgent::m_jvmti = 0;
-char* ClassLoadTraceAgent::m_option = 0;
-ofstream* ClassLoadTraceAgent::out = 0;
-
-ClassLoadTraceAgent::~ClassLoadTraceAgent() throw(AgentException)
-{
-    // Free allocated memory
-    m_jvmti->Deallocate(reinterpret_cast<unsigned char*>(m_option));
-	out->close();
-}
-
-void ClassLoadTraceAgent::Init(JavaVM *vm) const throw(AgentException){
-    jvmtiEnv *jvmti = 0;
-	jint ret = (vm)->GetEnv(reinterpret_cast<void**>(&jvmti), JVMTI_VERSION_1_0);
-	if (ret != JNI_OK || jvmti == 0) {
-		throw AgentException(JVMTI_ERROR_INTERNAL);
-	}
-	m_jvmti = jvmti;
-}
-
-bool ClassLoadTraceAgent::ParseOptions(const char* str) const throw(AgentException)
-{
-    if (str == 0)
-        return false;
-	const size_t len = strlen(str);
-	if (len == 0) 
-		return false;
-
-  	// Copy str to m_filepath
-	jvmtiError error;
-    error = m_jvmti->Allocate(len + 1,reinterpret_cast<unsigned char**>(&m_option));
-	CheckException(error);
-    strcpy(m_option, str);
-	if (strcmp(m_option, "help") == 0) {
-		cout << "Usage: java -agentlib:tracer=[help]|[output=filename]" << endl;
-		return false;
-	}
-	string option(m_option);
-	out = new ofstream(option.substr(option.find('=') + 1).c_str());
-	if (!out->is_open()) {
-		throw AgentException(JVMTI_ERROR_INTERNAL);
-	}
-	
+#include <string>
+#include <string.h>
+
+#include "ClassLoadTraceAgent.h"
+
+using namespace std;
+
+jvmtiEnv* ClassLoadTraceAgent::m_jvmti = 0;
+char* ClassLoadTraceAgent::m_option = 0;
+ofstream* ClassLoadTraceAgent::out = 0;
+
+ClassLoadTraceAgent::~ClassLoadTraceAgent() throw(AgentException)
+{
+    // Free allocated memory
+    m_jvmti->Deallocate(reinterpret_cast<unsigned char*>(m_option));
+	out->close();
+}
+
+void ClassLoadTraceAgent::Init(JavaVM *vm) const throw(AgentException){
+    jvmtiEnv *jvmti = 0;
+	jint ret = (vm)->GetEnv(reinterpret_cast<void**>(&jvmti), JVMTI_VERSION_1_0);
+	if (ret != JNI_OK || jvmti == 0) {
+		throw AgentException(JVMTI_ERROR_INTERNAL);
+	}
+	m_jvmti = jvmti;
+}
+
+bool ClassLoadTraceAgent::ParseOptions(const char* str) const throw(AgentException)
+{
+    if (str == 0)
+        return false;
+	const size_t len = strlen(str);
+	if (len == 0) 
+		return false;
+
+  	// Copy str to m_filepath
+	jvmtiError error;
+    error = m_jvmti->Allocate(len + 1,reinterpret_cast<unsigned char**>(&m_option));
+	CheckException(error);
+    strcpy(m_option, str);
+	if (strcmp(m_option, "help") == 0) {
+		cout << "Usage: java -agentlib:tracer=[help]|[output=filename]" << endl;
+		return false;
+	}
+	string option(m_option);
+	out = new ofstream(option.substr(option.find('=') + 1).c_str());
+	if (!out->is_open()) {
+		throw AgentException(JVMTI_ERROR_INTERNAL);
+	}
+	
 	*out << "Class Name Set File\n" << endl;
-	return true;
-}
-  
-void ClassLoadTraceAgent::RegisterEvent() const throw(AgentException)
-{
-    // Create a new callback
-    jvmtiEventCallbacks callbacks;
-    memset(&callbacks, 0, sizeof(callbacks));
-    callbacks.ClassLoad = &ClassLoadTraceAgent::HandleClassLoad;
-    
-    // Set callback
-    jvmtiError error;
-    error = m_jvmti->SetEventCallbacks(&callbacks, static_cast<jint>(sizeof(callbacks)));
-	CheckException(error);
-
-	// Set event notification mode
-	error = m_jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, 0);
-	CheckException(error);
-}
-
-void JNICALL ClassLoadTraceAgent::HandleClassLoad(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jclass klass)
-{
-	try {
-        jvmtiError error;
-		char* signature;
-        
-        // Get class signature
-        error = m_jvmti->GetClassSignature(klass, &signature, 0);
-        CheckException(error);
-		
-		transform(signature);
-		
-		*out << signature << endl;
-
-        error = m_jvmti->Deallocate(reinterpret_cast<unsigned char*>(signature));
-		CheckException(error);
-
-	} catch (AgentException& e) {
-		cout << "Error when enter HandleMethodEntry: " << e.what() << " [" << e.ErrCode() << "]";
-    }
-}
-
-
+	return true;
+}
+  
+void ClassLoadTraceAgent::RegisterEvent() const throw(AgentException)
+{
+    // Create a new callback
+    jvmtiEventCallbacks callbacks;
+    memset(&callbacks, 0, sizeof(callbacks));
+    callbacks.ClassLoad = &ClassLoadTraceAgent::HandleClassLoad;
+    
+    // Set callback
+    jvmtiError error;
+    error = m_jvmti->SetEventCallbacks(&callbacks, static_cast<jint>(sizeof(callbacks)));
+	CheckException(error);
+
+	// Set event notification mode
+	error = m_jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, 0);
+	CheckException(error);
+}
+
+void JNICALL ClassLoadTraceAgent::HandleClassLoad(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jclass klass)
+{
+	try {
+        jvmtiError error;
+		char* signature;
+        
+        // Get class signature
+        error = m_jvmti->GetClassSignature(klass, &signature, 0);
+        CheckException(error);
+		
+		transform(signature);
+		
+		*out << signature << endl;
+
+        error = m_jvmti->Deallocate(reinterpret_cast<unsigned char*>(signature));
+		CheckException(error);
+
+	} catch (AgentException& e) {
+		cout << "Error when enter HandleMethodEntry: " << e.what() << " [" << e.ErrCode() << "]";
+    }
+}
+
+

Propchange: harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.h?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.h (original)
+++ harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.h Mon Aug 17 07:35:16 2009
@@ -1,72 +1,72 @@
-#include <iostream>
-#include <fstream>
-#include <string>
-
-#include "jvmti.h"
-
-using namespace std;
-
-class AgentException 
-{
- public:
-	AgentException(jvmtiError err) {
-		m_error = err;
-	}
-
-	const char* what() const throw() { 
-		return "AgentException";
-	}
-
-	jvmtiError ErrCode() const throw() {
-		return m_error;
-	}
-
- private:
-	jvmtiError m_error;
-};
-
-
-class ClassLoadTraceAgent 
-{
- public:
-
-	ClassLoadTraceAgent() throw(AgentException){}
-
-	~ClassLoadTraceAgent() throw(AgentException);
-
-	void Init(JavaVM *vm) const throw(AgentException);
-        
-	bool ParseOptions(const char* str) const throw(AgentException);
-        
-	void RegisterEvent() const throw(AgentException);
-    
-	static void JNICALL HandleClassLoad(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jclass klass);
-
- private:
-	
-	static void transform(char *sig) {
-		int i = 0;
-		while (sig[i] != '\0') {
-			if (sig[i+1] == '/')
-				sig[i] = '.';
-			else
-				sig[i] = sig[i + 1];
-			i++;
-		}
-		sig[i-2] = '\0';
-	}
-	 
-	static void CheckException(jvmtiError error) throw(AgentException)
-	{
-		if (error != JVMTI_ERROR_NONE) {
-			throw AgentException(error);
-		}
-	}
-    
-	static jvmtiEnv* m_jvmti;
-	
-	static char* m_option;
-	
-	static ofstream* out;
-	
-};
+#include <iostream>
+#include <fstream>
+#include <string>
+
+#include "jvmti.h"
+
+using namespace std;
+
+class AgentException 
+{
+ public:
+	AgentException(jvmtiError err) {
+		m_error = err;
+	}
+
+	const char* what() const throw() { 
+		return "AgentException";
+	}
+
+	jvmtiError ErrCode() const throw() {
+		return m_error;
+	}
+
+ private:
+	jvmtiError m_error;
+};
+
+
+class ClassLoadTraceAgent 
+{
+ public:
+
+	ClassLoadTraceAgent() throw(AgentException){}
+
+	~ClassLoadTraceAgent() throw(AgentException);
+
+	void Init(JavaVM *vm) const throw(AgentException);
+        
+	bool ParseOptions(const char* str) const throw(AgentException);
+        
+	void RegisterEvent() const throw(AgentException);
+    
+	static void JNICALL HandleClassLoad(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jclass klass);
+
+ private:
+	
+	static void transform(char *sig) {
+		int i = 0;
+		while (sig[i] != '\0') {
+			if (sig[i+1] == '/')
+				sig[i] = '.';
+			else
+				sig[i] = sig[i + 1];
+			i++;
+		}
+		sig[i-2] = '\0';
+	}
+	 
+	static void CheckException(jvmtiError error) throw(AgentException)
+	{
+		if (error != JVMTI_ERROR_NONE) {
+			throw AgentException(error);
+		}
+	}
+    
+	static jvmtiEnv* m_jvmti;
+	
+	static char* m_option;
+	
+	static ofstream* out;
+	
+};

Propchange: harmony/enhanced/tools/trunk/minijre/native/ClassLoadTraceAgent.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/tools/trunk/minijre/native/Main.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/native/Main.cpp?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/native/Main.cpp (original)
+++ harmony/enhanced/tools/trunk/minijre/native/Main.cpp Mon Aug 17 07:35:16 2009
@@ -1,28 +1,28 @@
-#include "ClassLoadTraceAgent.h"
-
-using namespace std;
-
-JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
-{
-    try{
-        bool flag;
-        ClassLoadTraceAgent* agent = new ClassLoadTraceAgent();
-		agent->Init(vm);
+#include "ClassLoadTraceAgent.h"
+
+using namespace std;
+
+JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
+{
+    try{
+        bool flag;
+        ClassLoadTraceAgent* agent = new ClassLoadTraceAgent();
+		agent->Init(vm);
         flag = agent->ParseOptions(options);
-
+
 		if (flag == false) {
-
+
 			return JNI_OK;
-
-		}
-        agent->RegisterEvent();
-        
-    } catch (AgentException& e) {
-        cout << "Error when enter HandleMethodEntry: " << e.what() << " [" << e.ErrCode() << "]";
-		return JNI_ERR;
-	}
-    
-	return JNI_OK;
-}
-
-JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm) {}
+
+		}
+        agent->RegisterEvent();
+        
+    } catch (AgentException& e) {
+        cout << "Error when enter HandleMethodEntry: " << e.what() << " [" << e.ErrCode() << "]";
+		return JNI_ERR;
+	}
+    
+	return JNI_OK;
+}
+
+JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm) {}

Propchange: harmony/enhanced/tools/trunk/minijre/native/Main.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/tools/trunk/minijre/script/analyze.bat
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/tools/trunk/minijre/script/analyze.cmd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/tools/trunk/minijre/script/analyze.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/tools/trunk/minijre/script/jregen.bat
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/tools/trunk/minijre/script/jregen.cmd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/tools/trunk/minijre/script/jregen.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/CNSFileFormatException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/CNSFileFormatException.java?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/CNSFileFormatException.java (original)
+++ harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/CNSFileFormatException.java Mon Aug 17 07:35:16 2009
@@ -1,19 +1,19 @@
-package org.crazynut.harmony.minjre;
-
-/** 
- * Thrown when trying to read a .cns file and determines
- * that the file is malformed or otherwise cannot be interpreted as a
- * class name set file.
- *
- * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
- */
-public class CNSFileFormatException extends RuntimeException {
-    
-	public CNSFileFormatException() {
-        super();
-    }
-
-    public CNSFileFormatException(String s) {
-        super(s);
-    }
-}
+package org.crazynut.harmony.minjre;
+
+/** 
+ * Thrown when trying to read a .cns file and determines
+ * that the file is malformed or otherwise cannot be interpreted as a
+ * class name set file.
+ *
+ * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
+ */
+public class CNSFileFormatException extends RuntimeException {
+    
+	public CNSFileFormatException() {
+        super();
+    }
+
+    public CNSFileFormatException(String s) {
+        super(s);
+    }
+}

Propchange: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/CNSFileFormatException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/ClassNameSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/ClassNameSet.java?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/ClassNameSet.java (original)
+++ harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/ClassNameSet.java Mon Aug 17 07:35:16 2009
@@ -1,298 +1,298 @@
-package org.crazynut.harmony.minjre;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.FileNotFoundException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.HashMap;
-import java.util.regex.Pattern;
-
-/**
- * The data structure designed to contain a set of class & pack names 
- * and support fast class name retrieval. <p>
- * The data structure is associated with a type of file with the suffix 
- * of .cns, which contains a list of class & pack names. The format of
- * cns file is as following: <p>
- * =======================<p>
- * &nbspClass Name Set File<p>
- *
- * &nbspjava.io.File<p>
- * &nbspjava.util.HashMap<p>
- * &nbspjava.lang.*<p>
- * &nbsp.................<p>
- * =======================<p>
- * 
- * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
- */
-public class ClassNameSet {
-	
-	/**
-	 * The class name set.
-	 */
-	private HashMap<String, Object> classSet;
-	
-	/**
-	 * The package list.
-	 */
-	private LinkedList<String> packList;
-	
-	/**
-	 * The class name pattern.
-	 */
-	private static Pattern classNamePattern = 
-		Pattern.compile("([a-z0-9]+\\.)*[A-Z][a-zA-Z0-9_]*(\\$[a-zA-Z0-9][a-zA-Z0-9_]*)*(\\$[1-9][0-9]*)*");
-	
-	/**
-	 * The package name pattern.
-	 */
-	private static Pattern packNamePatter = 
-		Pattern.compile("([a-z0-9]+\\.)+\\*");
-	
-	/**
-	 * Decide whether the name is a valid class name.
-	 * 
-	 * @param name name
-	 * @return True if the name is a valid class name
-	 */
-	private boolean isClassName(String name) {
-		return classNamePattern.matcher(name).matches();
-	}
-	
-	/**
-	 * Decide whether the name is a valid package name.
-	 * 
-	 * @param name name
-	 * @return True if the name is a valid package name
-	 */
-	private boolean isPackName(String name) {
-		return packNamePatter.matcher(name).matches();
-	}
-	
-	/**
-	 * Add a package name to the list.<p>
-	 * If there are some package that covers the package, 
-	 * it will not be added to the list; if there are some
-	 * package covered by the package, it will be added and
-	 * replace the covered one.
-	 * 
-	 * @param packName
-	 */
-	private void addPack(String packName) {
-		Iterator<String> i = packList.iterator();
-		while (i.hasNext()) {
-			String pack = i.next();
-			if (packName.equals(pack)) {
-				return;
-			}
-		}
-		packList.add(packName);
-	}
-	
-	/**
-	 * Create new empty class name set.
-	 */
-	public ClassNameSet() {
-		classSet = new HashMap<String, Object>();
-		packList = new LinkedList<String>();
-	}
-	
-	public ClassNameSet(InputStream is) throws IOException, CNSFileFormatException {
-		this();
-		BufferedReader in = new BufferedReader(new InputStreamReader(is));
-		String newLine;
-		if (!(newLine = in.readLine()).equals("Class Name Set File")) {
-			in.close();
-			throw new CNSFileFormatException("The type of jre does not have a valid cns file.");
-		} else {
-			newLine = in.readLine();
-			while (newLine != null) {
-				// Ignore the empty lines
-				while (newLine != null && newLine.equals("\n")) {
-					newLine = in.readLine();
-				}
-				addName(newLine);
-				newLine = in.readLine();
-			}
-			in.close();
-		}
-	}
-
-	/**
-	 * Create new class name set from the given file.
-	 * 
-	 * @param file The java.io.File instance of the file
-	 * @throws FileNotFoundException
-	 * @throws IOException
-	 * @throws CNSFileFormatException
-	 */
-	public ClassNameSet(File file) throws FileNotFoundException, IOException, CNSFileFormatException {
-		this();
-		if (null == file) {
-			return;
-		}
-		if (file.exists() && file.isFile()) {
-			BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
-			String newLine;
-			if (!(newLine = in.readLine()).equals("Class Name Set File")) {
-				in.close();
-				throw new CNSFileFormatException("The file " + 
-						file.getPath() + " cannot be interpreted as a csn file.");
-			} else {
-				newLine = in.readLine();
-				while (newLine != null) {
-					// Ignore the empty lines
-					while (newLine != null && newLine.equals("\n")) {
-						newLine = in.readLine();
-					}
-					addName(newLine);
-					newLine = in.readLine();
-				}
-				in.close();
-			}
-		} else {
-			throw new FileNotFoundException("The file " + 
-					file.getPath() + " does not exist.");
-		}	
-	}
-	
-	/**
-	 * Create new class name set from the file at the given path.
-	 * 
-	 * @param fileName The path of the file
-	 * @throws FileNotFoundException
-	 * @throws IOException
-	 * @throws CNSFileFormatException
-	 */
-	public ClassNameSet(String fileName) throws FileNotFoundException, IOException, CNSFileFormatException {
-		this(null == fileName ? (File) null : new File(fileName));
-	}
-	
-	/**
-	 * Output the class name set to a cns file.
-	 * 
-	 * @param file The java.io.File instance of the file
-	 * @throws FileNotFoundException 
-	 */
-	public void toClassListFile(File file) throws FileNotFoundException, IOException {
-		if (null == file) {
-			return;
-		}
-		BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
-		out.write("Class Name Set File\n\n");
-		Iterator<String> i = classSet.keySet().iterator();
-		while (i.hasNext()) {
-			out.write(i.next() + "\n");
-		}
-		i = packList.iterator();
-		while (i.hasNext()) {
-			out.write(i.next() + "\n");
-		}
-		out.close();
-	}
-	
-	/**
-	 * Output the class name set to a cns file.
-	 * 
-	 * @param fileName The path of the file
-	 * @throws IOException 
-	 * @throws FileNotFoundException 
-	 */
-	public void toClassListFile(String fileName) throws FileNotFoundException, IOException {
-		toClassListFile(new File(fileName));
-	}
-	
-	/**
-	 * Add a name (class or package) to the class name set.<p>
-	 * If the name exists in the set or covered by some 
-	 * package in the set, it will not be added.
-	 * 
-	 * @param name The name to add
-	 */
-	public void addName(String name) {
-		// If the newline is a package name
-		if (isPackName(name)) {
-			addPack(name);
-		} else if (isClassName(name)){
-			classSet.put(name, null);
-		}
-	}
-	
-	/**
-	 * Merge another class name set to the current set.
-	 * 
-	 * @param anotherSet
-	 */
-	public void merge(ClassNameSet anotherSet) {
-		classSet.putAll(anotherSet.classSet);
-		Iterator<String> i = anotherSet.packList.iterator();
-		while (i.hasNext()) {
-			String newPack = i.next();
-			Iterator<String> j = packList.iterator();
-			while (j.hasNext()) {
-				if (newPack.equals(j.next())) {
-					i.remove();
-					break;
-				}
-			}
-		}
-		packList.addAll(anotherSet.packList);
-	}
-	
-	/**
-	 * Merge another class name set to the current set.
-	 * 
-	 * @param file The java.io.File instance of the file 
-	 * that contains the class name set
-	 * @throws IOException 
-	 * @throws CNSFileFormatException 
-	 * @throws FileNotFoundException 
-	 */
-	public void merge(File file) throws FileNotFoundException, CNSFileFormatException, IOException {
-		merge(new ClassNameSet(file));
-	}
-	
-	/**
-	 * Merge another class name set to the current set.
-	 * 
-	 * @param fileName The path of the file 
-	 * that contains the class name set
-	 * @throws IOException 
-	 * @throws CNSFileFormatException 
-	 * @throws FileNotFoundException 
-	 */
-	public void merge(String fileName) throws FileNotFoundException, CNSFileFormatException, IOException {
-		merge(null == fileName ? (File) null : new File(fileName));
-	}
-	
-	/**
-	 * Decide whether a class name exists in the set.
-	 * 
-	 * @param className The class name
-	 * @return True if the class name exists
-	 */
-	public boolean isClassIn(String className) {
-		if (false == isClassName(className)) {
-			return false;
-		}
-		if (classSet.containsKey(className)) {
-			return true;
-		}
-		Iterator<String> i = packList.iterator();
-		while (i.hasNext()) {
-			String packName = i.next();
-			if (packName.substring(0, packName.lastIndexOf('*'))
-					.equals(className.substring(0, className.lastIndexOf('.') + 1))) {
-				return true;
-			}
-		}
-		return false;
-	}
-}
+package org.crazynut.harmony.minjre;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.HashMap;
+import java.util.regex.Pattern;
+
+/**
+ * The data structure designed to contain a set of class & pack names 
+ * and support fast class name retrieval. <p>
+ * The data structure is associated with a type of file with the suffix 
+ * of .cns, which contains a list of class & pack names. The format of
+ * cns file is as following: <p>
+ * =======================<p>
+ * &nbspClass Name Set File<p>
+ *
+ * &nbspjava.io.File<p>
+ * &nbspjava.util.HashMap<p>
+ * &nbspjava.lang.*<p>
+ * &nbsp.................<p>
+ * =======================<p>
+ * 
+ * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
+ */
+public class ClassNameSet {
+	
+	/**
+	 * The class name set.
+	 */
+	private HashMap<String, Object> classSet;
+	
+	/**
+	 * The package list.
+	 */
+	private LinkedList<String> packList;
+	
+	/**
+	 * The class name pattern.
+	 */
+	private static Pattern classNamePattern = 
+		Pattern.compile("([a-z0-9]+\\.)*[A-Z][a-zA-Z0-9_]*(\\$[a-zA-Z0-9][a-zA-Z0-9_]*)*(\\$[1-9][0-9]*)*");
+	
+	/**
+	 * The package name pattern.
+	 */
+	private static Pattern packNamePatter = 
+		Pattern.compile("([a-z0-9]+\\.)+\\*");
+	
+	/**
+	 * Decide whether the name is a valid class name.
+	 * 
+	 * @param name name
+	 * @return True if the name is a valid class name
+	 */
+	private boolean isClassName(String name) {
+		return classNamePattern.matcher(name).matches();
+	}
+	
+	/**
+	 * Decide whether the name is a valid package name.
+	 * 
+	 * @param name name
+	 * @return True if the name is a valid package name
+	 */
+	private boolean isPackName(String name) {
+		return packNamePatter.matcher(name).matches();
+	}
+	
+	/**
+	 * Add a package name to the list.<p>
+	 * If there are some package that covers the package, 
+	 * it will not be added to the list; if there are some
+	 * package covered by the package, it will be added and
+	 * replace the covered one.
+	 * 
+	 * @param packName
+	 */
+	private void addPack(String packName) {
+		Iterator<String> i = packList.iterator();
+		while (i.hasNext()) {
+			String pack = i.next();
+			if (packName.equals(pack)) {
+				return;
+			}
+		}
+		packList.add(packName);
+	}
+	
+	/**
+	 * Create new empty class name set.
+	 */
+	public ClassNameSet() {
+		classSet = new HashMap<String, Object>();
+		packList = new LinkedList<String>();
+	}
+	
+	public ClassNameSet(InputStream is) throws IOException, CNSFileFormatException {
+		this();
+		BufferedReader in = new BufferedReader(new InputStreamReader(is));
+		String newLine;
+		if (!(newLine = in.readLine()).equals("Class Name Set File")) {
+			in.close();
+			throw new CNSFileFormatException("The type of jre does not have a valid cns file.");
+		} else {
+			newLine = in.readLine();
+			while (newLine != null) {
+				// Ignore the empty lines
+				while (newLine != null && newLine.equals("\n")) {
+					newLine = in.readLine();
+				}
+				addName(newLine);
+				newLine = in.readLine();
+			}
+			in.close();
+		}
+	}
+
+	/**
+	 * Create new class name set from the given file.
+	 * 
+	 * @param file The java.io.File instance of the file
+	 * @throws FileNotFoundException
+	 * @throws IOException
+	 * @throws CNSFileFormatException
+	 */
+	public ClassNameSet(File file) throws FileNotFoundException, IOException, CNSFileFormatException {
+		this();
+		if (null == file) {
+			return;
+		}
+		if (file.exists() && file.isFile()) {
+			BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+			String newLine;
+			if (!(newLine = in.readLine()).equals("Class Name Set File")) {
+				in.close();
+				throw new CNSFileFormatException("The file " + 
+						file.getPath() + " cannot be interpreted as a csn file.");
+			} else {
+				newLine = in.readLine();
+				while (newLine != null) {
+					// Ignore the empty lines
+					while (newLine != null && newLine.equals("\n")) {
+						newLine = in.readLine();
+					}
+					addName(newLine);
+					newLine = in.readLine();
+				}
+				in.close();
+			}
+		} else {
+			throw new FileNotFoundException("The file " + 
+					file.getPath() + " does not exist.");
+		}	
+	}
+	
+	/**
+	 * Create new class name set from the file at the given path.
+	 * 
+	 * @param fileName The path of the file
+	 * @throws FileNotFoundException
+	 * @throws IOException
+	 * @throws CNSFileFormatException
+	 */
+	public ClassNameSet(String fileName) throws FileNotFoundException, IOException, CNSFileFormatException {
+		this(null == fileName ? (File) null : new File(fileName));
+	}
+	
+	/**
+	 * Output the class name set to a cns file.
+	 * 
+	 * @param file The java.io.File instance of the file
+	 * @throws FileNotFoundException 
+	 */
+	public void toClassListFile(File file) throws FileNotFoundException, IOException {
+		if (null == file) {
+			return;
+		}
+		BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
+		out.write("Class Name Set File\n\n");
+		Iterator<String> i = classSet.keySet().iterator();
+		while (i.hasNext()) {
+			out.write(i.next() + "\n");
+		}
+		i = packList.iterator();
+		while (i.hasNext()) {
+			out.write(i.next() + "\n");
+		}
+		out.close();
+	}
+	
+	/**
+	 * Output the class name set to a cns file.
+	 * 
+	 * @param fileName The path of the file
+	 * @throws IOException 
+	 * @throws FileNotFoundException 
+	 */
+	public void toClassListFile(String fileName) throws FileNotFoundException, IOException {
+		toClassListFile(new File(fileName));
+	}
+	
+	/**
+	 * Add a name (class or package) to the class name set.<p>
+	 * If the name exists in the set or covered by some 
+	 * package in the set, it will not be added.
+	 * 
+	 * @param name The name to add
+	 */
+	public void addName(String name) {
+		// If the newline is a package name
+		if (isPackName(name)) {
+			addPack(name);
+		} else if (isClassName(name)){
+			classSet.put(name, null);
+		}
+	}
+	
+	/**
+	 * Merge another class name set to the current set.
+	 * 
+	 * @param anotherSet
+	 */
+	public void merge(ClassNameSet anotherSet) {
+		classSet.putAll(anotherSet.classSet);
+		Iterator<String> i = anotherSet.packList.iterator();
+		while (i.hasNext()) {
+			String newPack = i.next();
+			Iterator<String> j = packList.iterator();
+			while (j.hasNext()) {
+				if (newPack.equals(j.next())) {
+					i.remove();
+					break;
+				}
+			}
+		}
+		packList.addAll(anotherSet.packList);
+	}
+	
+	/**
+	 * Merge another class name set to the current set.
+	 * 
+	 * @param file The java.io.File instance of the file 
+	 * that contains the class name set
+	 * @throws IOException 
+	 * @throws CNSFileFormatException 
+	 * @throws FileNotFoundException 
+	 */
+	public void merge(File file) throws FileNotFoundException, CNSFileFormatException, IOException {
+		merge(new ClassNameSet(file));
+	}
+	
+	/**
+	 * Merge another class name set to the current set.
+	 * 
+	 * @param fileName The path of the file 
+	 * that contains the class name set
+	 * @throws IOException 
+	 * @throws CNSFileFormatException 
+	 * @throws FileNotFoundException 
+	 */
+	public void merge(String fileName) throws FileNotFoundException, CNSFileFormatException, IOException {
+		merge(null == fileName ? (File) null : new File(fileName));
+	}
+	
+	/**
+	 * Decide whether a class name exists in the set.
+	 * 
+	 * @param className The class name
+	 * @return True if the class name exists
+	 */
+	public boolean isClassIn(String className) {
+		if (false == isClassName(className)) {
+			return false;
+		}
+		if (classSet.containsKey(className)) {
+			return true;
+		}
+		Iterator<String> i = packList.iterator();
+		while (i.hasNext()) {
+			String packName = i.next();
+			if (packName.substring(0, packName.lastIndexOf('*'))
+					.equals(className.substring(0, className.lastIndexOf('.') + 1))) {
+				return true;
+			}
+		}
+		return false;
+	}
+}

Propchange: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/ClassNameSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/JreGenerator.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/JreGenerator.java?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/JreGenerator.java (original)
+++ harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/JreGenerator.java Mon Aug 17 07:35:16 2009
@@ -1,312 +1,312 @@
-package org.crazynut.harmony.minjre;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileNotFoundException;
-import java.util.Iterator;
-import java.util.Vector;
-import java.util.HashMap;
-import java.util.Enumeration;
-import java.util.Map.Entry;
-import java.util.jar.JarFile;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-
-/**
- * The minimum JRE generator, which generate a new JRE
- * from a complete JRE according to a reserved class list.
- * 
- * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
- */
-public class JreGenerator {
-	
-	/**
-	 * The class set which should be reserved in jre.
-	 */
-	private ClassNameSet reservedClasses = null;
-	
-	/**
-	 * The length of the buffer used in jar file IO.
-	 */
-	private static final int BUFF_LEN = 1024;
-	
-	/**
-	 * Repack jar file according to the reserved class list.
-	 * 
-	 * @param fromPath the origin jar file path
-	 * @param toPath the new jar file path
-	 */
-	private void repackJar(final String fromPath, final String toPath) {
-		int count = 0;
-		HashMap<String, Boolean> isDirEmpty = new HashMap<String, Boolean>(); 
-		Vector<JarEntry> entryList = new Vector<JarEntry>();
-		try {
-			JarFile jar = new JarFile(fromPath);
-			Enumeration<JarEntry> entries = jar.entries();
-			while (entries.hasMoreElements()) {
-				JarEntry entry = (JarEntry) entries.nextElement();
-				if (entry.getName().endsWith(".class")) {
-					String classFileName = entry.getName().replace('/', '.');
-					String className = classFileName.substring(0,
-							classFileName.lastIndexOf('.'));
-					if (!reservedClasses.isClassIn(className)) {
-						continue;
-					} else {
-						count++;
-					}
-				}
-				if (entry.isDirectory()) {
-					Boolean isEmpty = Boolean.TRUE;
-					Iterator<JarEntry> i = entryList.iterator();
-					while (i.hasNext()) {
-						JarEntry temp = i.next();
-						if (!temp.isDirectory() 
-								&& temp.getName().startsWith(entry.getName())) {
-							isEmpty = Boolean.FALSE;
-						}
-					}
-					isDirEmpty.put(entry.getName(), isEmpty);
-				} else {
-					entryList.add(entry);
-					Iterator<Entry<String, Boolean>> i = 
-						isDirEmpty.entrySet().iterator();
-					while (i.hasNext()) {
-						Entry<String, Boolean> dirEntry = i.next();
-						String dirName = dirEntry.getKey();
-						if (entry.getName().startsWith(dirName) 
-							&& isDirEmpty.containsKey(dirName) 
-							&& isDirEmpty.get(dirName).equals(Boolean.TRUE)) {
-							isDirEmpty.put(dirName, Boolean.FALSE);
-						}
-					}
-				}
-			}
-			if (count != 0 && isDirEmpty.containsValue(Boolean.FALSE)) {
-				int byteRead = 0;
-				byte[] buffer = new byte[BUFF_LEN];
-				Iterator<JarEntry> i = entryList.iterator();
-				JarOutputStream out = 
-					new JarOutputStream(new FileOutputStream(toPath));
-				while (i.hasNext()) {
-					JarEntry temp = i.next();
-					if (temp.isDirectory() && isDirEmpty.get(temp.getName())
-							.equals(Boolean.TRUE)) {
-						continue;
-					}
-					InputStream in = jar.getInputStream(temp);
+package org.crazynut.harmony.minjre;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.Map.Entry;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+/**
+ * The minimum JRE generator, which generate a new JRE
+ * from a complete JRE according to a reserved class list.
+ * 
+ * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
+ */
+public class JreGenerator {
+	
+	/**
+	 * The class set which should be reserved in jre.
+	 */
+	private ClassNameSet reservedClasses = null;
+	
+	/**
+	 * The length of the buffer used in jar file IO.
+	 */
+	private static final int BUFF_LEN = 1024;
+	
+	/**
+	 * Repack jar file according to the reserved class list.
+	 * 
+	 * @param fromPath the origin jar file path
+	 * @param toPath the new jar file path
+	 */
+	private void repackJar(final String fromPath, final String toPath) {
+		int count = 0;
+		HashMap<String, Boolean> isDirEmpty = new HashMap<String, Boolean>(); 
+		Vector<JarEntry> entryList = new Vector<JarEntry>();
+		try {
+			JarFile jar = new JarFile(fromPath);
+			Enumeration<JarEntry> entries = jar.entries();
+			while (entries.hasMoreElements()) {
+				JarEntry entry = (JarEntry) entries.nextElement();
+				if (entry.getName().endsWith(".class")) {
+					String classFileName = entry.getName().replace('/', '.');
+					String className = classFileName.substring(0,
+							classFileName.lastIndexOf('.'));
+					if (!reservedClasses.isClassIn(className)) {
+						continue;
+					} else {
+						count++;
+					}
+				}
+				if (entry.isDirectory()) {
+					Boolean isEmpty = Boolean.TRUE;
+					Iterator<JarEntry> i = entryList.iterator();
+					while (i.hasNext()) {
+						JarEntry temp = i.next();
+						if (!temp.isDirectory() 
+								&& temp.getName().startsWith(entry.getName())) {
+							isEmpty = Boolean.FALSE;
+						}
+					}
+					isDirEmpty.put(entry.getName(), isEmpty);
+				} else {
+					entryList.add(entry);
+					Iterator<Entry<String, Boolean>> i = 
+						isDirEmpty.entrySet().iterator();
+					while (i.hasNext()) {
+						Entry<String, Boolean> dirEntry = i.next();
+						String dirName = dirEntry.getKey();
+						if (entry.getName().startsWith(dirName) 
+							&& isDirEmpty.containsKey(dirName) 
+							&& isDirEmpty.get(dirName).equals(Boolean.TRUE)) {
+							isDirEmpty.put(dirName, Boolean.FALSE);
+						}
+					}
+				}
+			}
+			if (count != 0 && isDirEmpty.containsValue(Boolean.FALSE)) {
+				int byteRead = 0;
+				byte[] buffer = new byte[BUFF_LEN];
+				Iterator<JarEntry> i = entryList.iterator();
+				JarOutputStream out = 
+					new JarOutputStream(new FileOutputStream(toPath));
+				while (i.hasNext()) {
+					JarEntry temp = i.next();
+					if (temp.isDirectory() && isDirEmpty.get(temp.getName())
+							.equals(Boolean.TRUE)) {
+						continue;
+					}
+					InputStream in = jar.getInputStream(temp);
 					//out.putNextEntry(temp);
-
+
 					JarEntry newTemp = new JarEntry(temp);
-
-					newTemp.setCompressedSize(-1);
-					out.putNextEntry(newTemp);
-					while ((byteRead = in.read(buffer)) != -1) {
-						out.write(buffer, 0, byteRead);
-					}
-					in.close();
-					out.flush();
-					out.closeEntry();
-				}
-				out.close();
-			}
-		} catch (IOException e) {
-			System.err.println("Repacking from " + fromPath 
-					+ " to " + toPath + " fails with IO problem.");
-			e.printStackTrace();
-		}
-	}
-	
-	/**
-	 * Copy directory to another place.
-	 * 
-	 * @param fromPath the origin directory path
-	 * @param toPath the aim directory path
-	 * @param jarNeedRepack set true if jar files
-	 *  in the directory need repacking
-	 * @throws Exception Throws when the directory toPath cannot be created
-	 */
-	private void copyDirectory(final String fromPath, 
-			final String toPath, final boolean jarNeedRepack) throws Exception {
-		if (!(new File(toPath).mkdirs())) {
-			throw new Exception("Directory " + toPath 
-					+ "cannot be created. JRE generation fails.");
-		}
-		File[] fileList = new File(fromPath).listFiles();
-		for (int i = 0; i < fileList.length; i++) {
-			if (fileList[i].isFile() 
-				&& !fileList[i].getName().endsWith("-src.jar") 
-				&& !fileList[i].getName().equals("luni-kernel-stubs.jar")) {
-				if (jarNeedRepack && fileList[i].getName().endsWith("jar")) {
-					repackJar(fileList[i].getAbsolutePath(), 
-							toPath + File.separator + fileList[i].getName());
-				} else {
-					copyFile(fileList[i].getAbsolutePath(), 
-							toPath + File.separator + fileList[i].getName());
-				}
-			} else if (fileList[i].isDirectory()) {
-				copyDirectory(fileList[i].getAbsolutePath(), 
-						toPath + File.separator + fileList[i].getName(), 
-						jarNeedRepack);
-			}
-		}
-	}
-	
-	/**
-	 * Copy file to another place.
-	 * 
-	 * @param fromPath the origin file path
-	 * @param toPath the aim file path
-	 */
-	private void copyFile(final String fromPath, final String toPath) {
-        try {
-        	int byteread = 0;
-            byte[] buffer = new byte[BUFF_LEN];
-        	InputStream in = new FileInputStream(fromPath);
-            OutputStream out = new FileOutputStream(toPath);
-            while ((byteread = in.read(buffer)) != -1) {
-            	out.write(buffer, 0, byteread);
-            }
-            in.close();
-            out.close();
-        } catch (IOException e) {
-        	System.err.println("IO problem encountered when trying copy file " 
-        			+ fromPath + " to " + toPath + ".");
-            e.printStackTrace();
-        } 
-	}
-	
-	/**
-	 * Constructor.
-	 * 
-	 * @param jre the jre type
-	 *
-	 */
-	public JreGenerator(final String jre) {
-		try {
-			reservedClasses = new ClassNameSet(this.getClass().getResourceAsStream("conf/" + jre + ".cns"));
-		} catch (CNSFileFormatException e) {
-			System.err.println("This type of jre does not has a valid cns file.");
-			e.printStackTrace();
-		} catch (IOException e) {
-			System.err.println("This type of jre is not supported.");
-			e.printStackTrace();
-		}
-	}
-
-	
-	/**
-	 * Add reserved classes from a ClassNameSet file.
-	 * 
-	 * @param fileName the file path of the cns file
-	 */
-	public final void addReservedClasses(final String fileName) {
-		addReservedClasses(null == fileName ? (File) null : new File(fileName));
-	}
-	
-	/**
-	 * Add reserved classes from a ClassNameSet file.
-	 * 
-	 * @param file the java.io.File instance of the cns file
-	 */
-	public final void addReservedClasses(final File file) {
-		try {
-			reservedClasses.merge(file);
-		} catch (FileNotFoundException e) {
-			System.err.println("The file " 
-					+ file.getAbsolutePath() + " does not exist.");
-			e.printStackTrace(); 
-		} catch (CNSFileFormatException e) {
-			System.err.println("The file " 
-					+ file.getAbsolutePath() + " is not a valid cns file.");
-			e.printStackTrace();
-		} catch (IOException e) {
-			System.err.println("IO problem encountered " 
-					+ "when trying to open and read from "  
-					+ file.getAbsolutePath() + ".");
-			e.printStackTrace();
-		}
-	}
-	
-	/**
-	 * Add reserved classes from a ClassNameSet instance.
-	 * 
-	 * @param cns the ClassNameSet instance
-	 */
-	public final void addReservedClasses(final ClassNameSet cns) {
-		reservedClasses.merge(cns);
-	}
-	
-	/**
-	 * Set the reserved classes set to the ClassNameSet 
-	 * instance built from a cns file.
-	 * 
-	 * @param fileName the path of the cns file
-	 */
-	public final void setReservedClasses(final String fileName) {
-		setReservedClasses(null == fileName ? (File) null : new File(fileName));
-	}
-	
-	/**
-	 * Set the reserved classes set to the ClassNameSet 
-	 * instance built from a cns file.
-	 * 
-	 * @param file the java.io.File instance of the cns file
-	 */
-	public final void setReservedClasses(final File file) {
-		try {
-			reservedClasses = new ClassNameSet(file);
-		} catch (FileNotFoundException e) {
-			System.err.println("The file " 
-					+ file.getAbsolutePath() + " does not exist.");
-			e.printStackTrace(); 
-		} catch (CNSFileFormatException e) {
-			System.err.println("The file " 
-					+ file.getAbsolutePath() + " is not a valid cns file.");
-			e.printStackTrace();
-		} catch (IOException e) {
-			System.err.println("IO problem encountered " 
-					+ "when trying to open and read from "  
-					+ file.getAbsolutePath() + ".");
-			e.printStackTrace();
-		}
-	}
-	
-	/**
-	 * Set the reserved classes set to the ClassNameSet instance.
-	 * 
-	 * @param cns the ClassNameSet instance
-	 */
-	public final void setReservedClasses(final ClassNameSet cns) {
-		reservedClasses = cns;
-	}
-	
-	/**
-	 * Generate minimum jre from the origin jre 
-	 * according to the reserved class list.
-	 * 
-	 * @param fromPath the origin jre path
-	 * @param toPath the aim jre path
-	 */
-	public final void generateMinJre(final String fromPath, 
-			final String toPath) {
-		File[] fileList = new File(fromPath).listFiles();
-		for (int i = 0; i < fileList.length; i++) {
-			if (fileList[i].isDirectory()) {
-				try {
-					copyDirectory(fileList[i].getAbsolutePath(), 
-							toPath + File.separator + fileList[i].getName(), 
-							fileList[i].getName().equals("lib"));
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
-			} else if (fileList[i].isFile()) {
-				copyFile(fileList[i].getAbsolutePath(), 
-						toPath + File.separator + fileList[i].getName());
-			}
-		}
-	}
-}
+
+					newTemp.setCompressedSize(-1);
+					out.putNextEntry(newTemp);
+					while ((byteRead = in.read(buffer)) != -1) {
+						out.write(buffer, 0, byteRead);
+					}
+					in.close();
+					out.flush();
+					out.closeEntry();
+				}
+				out.close();
+			}
+		} catch (IOException e) {
+			System.err.println("Repacking from " + fromPath 
+					+ " to " + toPath + " fails with IO problem.");
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * Copy directory to another place.
+	 * 
+	 * @param fromPath the origin directory path
+	 * @param toPath the aim directory path
+	 * @param jarNeedRepack set true if jar files
+	 *  in the directory need repacking
+	 * @throws Exception Throws when the directory toPath cannot be created
+	 */
+	private void copyDirectory(final String fromPath, 
+			final String toPath, final boolean jarNeedRepack) throws Exception {
+		if (!(new File(toPath).mkdirs())) {
+			throw new Exception("Directory " + toPath 
+					+ "cannot be created. JRE generation fails.");
+		}
+		File[] fileList = new File(fromPath).listFiles();
+		for (int i = 0; i < fileList.length; i++) {
+			if (fileList[i].isFile() 
+				&& !fileList[i].getName().endsWith("-src.jar") 
+				&& !fileList[i].getName().equals("luni-kernel-stubs.jar")) {
+				if (jarNeedRepack && fileList[i].getName().endsWith("jar")) {
+					repackJar(fileList[i].getAbsolutePath(), 
+							toPath + File.separator + fileList[i].getName());
+				} else {
+					copyFile(fileList[i].getAbsolutePath(), 
+							toPath + File.separator + fileList[i].getName());
+				}
+			} else if (fileList[i].isDirectory()) {
+				copyDirectory(fileList[i].getAbsolutePath(), 
+						toPath + File.separator + fileList[i].getName(), 
+						jarNeedRepack);
+			}
+		}
+	}
+	
+	/**
+	 * Copy file to another place.
+	 * 
+	 * @param fromPath the origin file path
+	 * @param toPath the aim file path
+	 */
+	private void copyFile(final String fromPath, final String toPath) {
+        try {
+        	int byteread = 0;
+            byte[] buffer = new byte[BUFF_LEN];
+        	InputStream in = new FileInputStream(fromPath);
+            OutputStream out = new FileOutputStream(toPath);
+            while ((byteread = in.read(buffer)) != -1) {
+            	out.write(buffer, 0, byteread);
+            }
+            in.close();
+            out.close();
+        } catch (IOException e) {
+        	System.err.println("IO problem encountered when trying copy file " 
+        			+ fromPath + " to " + toPath + ".");
+            e.printStackTrace();
+        } 
+	}
+	
+	/**
+	 * Constructor.
+	 * 
+	 * @param jre the jre type
+	 *
+	 */
+	public JreGenerator(final String jre) {
+		try {
+			reservedClasses = new ClassNameSet(this.getClass().getResourceAsStream("conf/" + jre + ".cns"));
+		} catch (CNSFileFormatException e) {
+			System.err.println("This type of jre does not has a valid cns file.");
+			e.printStackTrace();
+		} catch (IOException e) {
+			System.err.println("This type of jre is not supported.");
+			e.printStackTrace();
+		}
+	}
+
+	
+	/**
+	 * Add reserved classes from a ClassNameSet file.
+	 * 
+	 * @param fileName the file path of the cns file
+	 */
+	public final void addReservedClasses(final String fileName) {
+		addReservedClasses(null == fileName ? (File) null : new File(fileName));
+	}
+	
+	/**
+	 * Add reserved classes from a ClassNameSet file.
+	 * 
+	 * @param file the java.io.File instance of the cns file
+	 */
+	public final void addReservedClasses(final File file) {
+		try {
+			reservedClasses.merge(file);
+		} catch (FileNotFoundException e) {
+			System.err.println("The file " 
+					+ file.getAbsolutePath() + " does not exist.");
+			e.printStackTrace(); 
+		} catch (CNSFileFormatException e) {
+			System.err.println("The file " 
+					+ file.getAbsolutePath() + " is not a valid cns file.");
+			e.printStackTrace();
+		} catch (IOException e) {
+			System.err.println("IO problem encountered " 
+					+ "when trying to open and read from "  
+					+ file.getAbsolutePath() + ".");
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * Add reserved classes from a ClassNameSet instance.
+	 * 
+	 * @param cns the ClassNameSet instance
+	 */
+	public final void addReservedClasses(final ClassNameSet cns) {
+		reservedClasses.merge(cns);
+	}
+	
+	/**
+	 * Set the reserved classes set to the ClassNameSet 
+	 * instance built from a cns file.
+	 * 
+	 * @param fileName the path of the cns file
+	 */
+	public final void setReservedClasses(final String fileName) {
+		setReservedClasses(null == fileName ? (File) null : new File(fileName));
+	}
+	
+	/**
+	 * Set the reserved classes set to the ClassNameSet 
+	 * instance built from a cns file.
+	 * 
+	 * @param file the java.io.File instance of the cns file
+	 */
+	public final void setReservedClasses(final File file) {
+		try {
+			reservedClasses = new ClassNameSet(file);
+		} catch (FileNotFoundException e) {
+			System.err.println("The file " 
+					+ file.getAbsolutePath() + " does not exist.");
+			e.printStackTrace(); 
+		} catch (CNSFileFormatException e) {
+			System.err.println("The file " 
+					+ file.getAbsolutePath() + " is not a valid cns file.");
+			e.printStackTrace();
+		} catch (IOException e) {
+			System.err.println("IO problem encountered " 
+					+ "when trying to open and read from "  
+					+ file.getAbsolutePath() + ".");
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * Set the reserved classes set to the ClassNameSet instance.
+	 * 
+	 * @param cns the ClassNameSet instance
+	 */
+	public final void setReservedClasses(final ClassNameSet cns) {
+		reservedClasses = cns;
+	}
+	
+	/**
+	 * Generate minimum jre from the origin jre 
+	 * according to the reserved class list.
+	 * 
+	 * @param fromPath the origin jre path
+	 * @param toPath the aim jre path
+	 */
+	public final void generateMinJre(final String fromPath, 
+			final String toPath) {
+		File[] fileList = new File(fromPath).listFiles();
+		for (int i = 0; i < fileList.length; i++) {
+			if (fileList[i].isDirectory()) {
+				try {
+					copyDirectory(fileList[i].getAbsolutePath(), 
+							toPath + File.separator + fileList[i].getName(), 
+							fileList[i].getName().equals("lib"));
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			} else if (fileList[i].isFile()) {
+				copyFile(fileList[i].getAbsolutePath(), 
+						toPath + File.separator + fileList[i].getName());
+			}
+		}
+	}
+}

Propchange: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/JreGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/StaticDependencyAnalyzer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/StaticDependencyAnalyzer.java?rev=804884&r1=804883&r2=804884&view=diff
==============================================================================
--- harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/StaticDependencyAnalyzer.java (original)
+++ harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/StaticDependencyAnalyzer.java Mon Aug 17 07:35:16 2009
@@ -1,304 +1,304 @@
-package org.crazynut.harmony.minjre;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Vector;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import org.apache.bcel.classfile.JavaClass;
-import org.apache.bcel.classfile.ClassParser;
-import org.apache.bcel.classfile.Constant;
-import org.apache.bcel.classfile.ConstantClass;
-import org.apache.bcel.classfile.ConstantPool;
-import org.apache.bcel.classfile.ConstantUtf8;
-import org.apache.bcel.classfile.ClassFormatException;
-
-/**
- * A dependency analyzer implementation to examine 
- * what jre classes a certain java application depends on.
- * 
- * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
- */
-public class StaticDependencyAnalyzer {
-	
-	/**
-	 * The application class set.
-	 */
-	private Vector<JavaClass> rootClasses;
-	
-	/**
-	 * The jre class set.
-	 */
-	private HashMap<String, JavaClass> jreClasses;
-	
-	/**
-	 * The class paths, including jars and directories 
-	 * containing the application classes.
-	 */
-	private Vector<File> classPaths;
-	
-	/**
-	 * The jre path.
-	 */
-	private File jrePath;
-	
-	/**
-	 * True if the root class set has been built already.<p>
-	 * False if the root class set has not been built yet.
-	 */
-	private boolean isRootClassesBuilt;
-	
-	/**
-	 * True if the jre class set has been built already.<p>
-	 * False if the jre class set has been built yet.
-	 */
-	private boolean isJreClassesBuilt;
-	
-	/**
-	 * Constructor.
-	 */
-	public StaticDependencyAnalyzer() {
-		rootClasses = new Vector<JavaClass>();
-		jreClasses = new HashMap<String, JavaClass>();
-		classPaths = new Vector<File>();
-		jrePath = null;
-		isRootClassesBuilt = false;
-		isJreClassesBuilt = false;
-	}
-	
-	/**
-	 * Get class set from a directory.
-	 * 
-	 * @param dirPath the directory path that we get java classes from
-	 * @return the java classes we get from the directory
-	 */
-	private Vector<JavaClass> getJavaClassFromDir(final File dirpath) {
-		Vector<JavaClass> dirClasses = new Vector<JavaClass>();
-		File[] fileList = dirpath.listFiles();
-		for (int i = 0; i < fileList.length; i++) {
-			if (fileList[i].isFile()) {
-				if (fileList[i].getPath().endsWith(".class")) {
-					try {
-						dirClasses.add(new ClassParser(
-								fileList[i].getPath()).parse());
-					} catch (ClassFormatException e) {
-						System.err.println("The file " + fileList[i].getPath() +
-								"ends with .class " +
-								"but cannot be interpreted as a class file.");
-						e.printStackTrace();
-					} catch (IOException e) {
-						System.err.println("IO problem(s) detected when paring " 
-								+ "the file " + fileList[i].getPath() + ".");
-						e.printStackTrace();
-					}
-				} else if (fileList[i].getPath().endsWith(".jar")) {
-					dirClasses.addAll(getJavaClassFromJar(fileList[i]));
-				}
-			} else if (fileList[i].isDirectory()) {
-				dirClasses.addAll(getJavaClassFromDir(fileList[i]));
-			}
-		}
-		return dirClasses;
-	}
-	/**
-	 * Get JavaClass object list from a jar file.
-	 * 
-	 * @param jarPath the jar file path that we get java classes from
-	 * @return the java classes we get from jarPath
-	 */
-	private Vector<JavaClass> getJavaClassFromJar(final File jarPath) {
-		Vector<JavaClass> jarClasses = new Vector<JavaClass>();
-		if (!jarPath.getPath().endsWith(".jar")) {
-			return null;
-		}
-		try {
-			JarFile jarFile = new JarFile(jarPath);
-			Enumeration<JarEntry> entries = jarFile.entries();
-			while (entries.hasMoreElements()) {
-				JarEntry entry = entries.nextElement();
-				String name = entry.getName();
-				if (name.endsWith(".class")) {
-					jarClasses.add(new ClassParser(
-							jarFile.getInputStream(entry), 
-							name.substring(name.lastIndexOf('/') + 1)).parse());
-				}
-			}
-		} catch (IOException e) {
-			System.err.println("IO problem encountered " 
-					+ "when trying to get classes from " + jarPath + ".");
-			e.printStackTrace();
-		}
-		return jarClasses;
-	}
-	
-	/**
-	 * Build class set from the class paths added before.
-	 */
-	private void buildRootClasses() {
-		Iterator<File> i = classPaths.iterator();
-		while (i.hasNext()) {
-			File classPath = i.next();
-			if (classPath.isFile()) {
-				if (classPath.getName().endsWith(".jar")) {
-					rootClasses.addAll(getJavaClassFromJar(classPath));
-				} else if (classPath.getName().endsWith(".class")) {
-					try {
-						rootClasses.add(new ClassParser(
-								classPath.getAbsolutePath()).parse());
-					} catch (ClassFormatException e) {
-						System.err.println(classPath.getAbsolutePath()  
-								+ " is not a valid class file.");
-						e.printStackTrace();
-					} catch (IOException e) {
-						System.err.println("IO problem encountered " 
-								+ "when trying to parse " 
-								+ classPath.getAbsolutePath() + ".");
-						e.printStackTrace();
-					}
-				}
-			} else if (classPath.isDirectory()) {
-				rootClasses.addAll(getJavaClassFromDir(classPath));
-			}
-		}
-		isRootClassesBuilt = true;
-	}
-	
-	/**
-	 * Build class set from the jre path set before.
-	 */
-	private void buildJreClasses() {
-		if (jrePath != null) {
-			Vector<JavaClass> jreClassList = getJavaClassFromDir(jrePath);
-			Iterator<JavaClass> i = jreClassList.iterator();
-			while (i.hasNext()) {
-				JavaClass javaClazz = i.next();
-				jreClasses.put(javaClazz.getClassName(), javaClazz);
-			}
-			isJreClassesBuilt = true;
-		}
-	}
-	
-	/**
-	 * Add a class path to class path set. A class path can be 
-	 * a file directory or a jar file.
-	 * 
-	 * @param pathName The name of the class path add to class path set
-	 */
-	public final void addClassPath(final String pathName) {
-		File newpath = new File(pathName);
-		if (newpath.exists()) {
-			classPaths.add(newpath);
-			// Root class path is modified, 
-			// set it to false to require rebuilding.
-			isRootClassesBuilt = false;
-		}
-	}
-	
-	/**
-	 * Set the path of the lib directory in JRE.
-	 * 
-	 * @param dirName The path of the lib directory in JRE
-	 */
-	public final void setJreLibPath(final String dirName) {
-		File jreDir = new File(dirName);
-		if (jreDir.exists() && jreDir.isDirectory()) {
-			jrePath = jreDir;
-			// Jre class path is modified, 
-			// set it to false to require rebuilding.
-			isJreClassesBuilt = false;
-		}
-	}
-	
-	/**
-	 * Get the dependent class set.
-	 * 
-	 * @return the dependent class set
-	 */
-	public final ClassNameSet getDependentClasses() {
-		Vector<JavaClass> workList = new Vector<JavaClass>();
-		ClassNameSet result = new ClassNameSet();
-		
-		// Build root classes and jre classes in the first time
-		// or rebuild them when they are modified.
-		if (!isRootClassesBuilt) {
-			buildRootClasses();
-		}
-		if (!isJreClassesBuilt) {
-			buildJreClasses();
-		}
-		
-		// Add basic dependency 
-		workList.addAll(rootClasses);
-		Iterator<String> keyIterator = jreClasses.keySet().iterator();
-		while (keyIterator.hasNext()) {
-			String className = keyIterator.next();
-			if (className.startsWith("java.lang.")) {
-				workList.add(jreClasses.get(className));
-				result.addName(className);
-			}
-		}
-		
-		// Traverse the worklist to decide the classes that each class depends on in the worklist.
-		// These "depended" classes are added into the worklist and result if they have not been in the result yet.
-		// The algorithm ends when the index pointer reach the end of the worklist.
-		// A dependency closure will be built with the above algorithm.
-		int i = 0;
-		while (i < workList.size()) {
-			JavaClass javaClazz = workList.elementAt(i);
-			// Get depended classes from the constant pool
-			ConstantPool cp = javaClazz.getConstantPool();
-			Constant[] carray = cp.getConstantPool();
-			for (int j = 0; j < carray.length; j++) {
-				if (carray[j] instanceof ConstantClass) {
-					int index = ((ConstantClass) carray[j]).getNameIndex();
-					String className = ((ConstantUtf8) carray[index])
-						.getBytes().replace('/', '.');
-					if (!result.isClassIn(className) 
-							&& jreClasses.containsKey(className)) {
-						workList.add(jreClasses.get(className));
-						result.addName(className);
-					}
-				}
-			}
-			// Get interfaces
-			String[] interfaceNames = javaClazz.getInterfaceNames();
-			for (int j = 0; j < interfaceNames.length; j++) {
-				if (!result.isClassIn(interfaceNames[j]) 
-						&& jreClasses.containsKey(interfaceNames[j])) {
-					workList.add(jreClasses.get(interfaceNames[j]));
-					result.addName(interfaceNames[j]);
-				}
-			}
-			// Get superclass
-			String superClassName = javaClazz.getSuperclassName();
-			if (!result.isClassIn(superClassName) 
-					&& jreClasses.containsKey(superClassName)) {
-				workList.add(jreClasses.get(superClassName));
-				result.addName(superClassName);
-			}
-			i++;
-		}
-		return result;
-	}
-	
-	/**
-	 * Get the dependent class set and write it to file.
-	 * 
-	 * @param fileName the file that will contain the dependent class set
-	 */
-	public final void getDependentClasses(final String fileName) {
-		ClassNameSet result = getDependentClasses();
-		try {
-			result.toClassListFile(fileName);
-		} catch (IOException e) {
-			System.err.println("Problem encoutered " 
-					+ "when trying to create file " 
-					+ fileName + " or write to it.");
-			e.printStackTrace();
-		}
-	}
-}
+package org.crazynut.harmony.minjre;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.ClassParser;
+import org.apache.bcel.classfile.Constant;
+import org.apache.bcel.classfile.ConstantClass;
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.classfile.ConstantUtf8;
+import org.apache.bcel.classfile.ClassFormatException;
+
+/**
+ * A dependency analyzer implementation to examine 
+ * what jre classes a certain java application depends on.
+ * 
+ * @author  <A HREF="mailto:daniel.gong.fudan@gmail.com">Ling-Hui Gong</A>
+ */
+public class StaticDependencyAnalyzer {
+	
+	/**
+	 * The application class set.
+	 */
+	private Vector<JavaClass> rootClasses;
+	
+	/**
+	 * The jre class set.
+	 */
+	private HashMap<String, JavaClass> jreClasses;
+	
+	/**
+	 * The class paths, including jars and directories 
+	 * containing the application classes.
+	 */
+	private Vector<File> classPaths;
+	
+	/**
+	 * The jre path.
+	 */
+	private File jrePath;
+	
+	/**
+	 * True if the root class set has been built already.<p>
+	 * False if the root class set has not been built yet.
+	 */
+	private boolean isRootClassesBuilt;
+	
+	/**
+	 * True if the jre class set has been built already.<p>
+	 * False if the jre class set has been built yet.
+	 */
+	private boolean isJreClassesBuilt;
+	
+	/**
+	 * Constructor.
+	 */
+	public StaticDependencyAnalyzer() {
+		rootClasses = new Vector<JavaClass>();
+		jreClasses = new HashMap<String, JavaClass>();
+		classPaths = new Vector<File>();
+		jrePath = null;
+		isRootClassesBuilt = false;
+		isJreClassesBuilt = false;
+	}
+	
+	/**
+	 * Get class set from a directory.
+	 * 
+	 * @param dirPath the directory path that we get java classes from
+	 * @return the java classes we get from the directory
+	 */
+	private Vector<JavaClass> getJavaClassFromDir(final File dirpath) {
+		Vector<JavaClass> dirClasses = new Vector<JavaClass>();
+		File[] fileList = dirpath.listFiles();
+		for (int i = 0; i < fileList.length; i++) {
+			if (fileList[i].isFile()) {
+				if (fileList[i].getPath().endsWith(".class")) {
+					try {
+						dirClasses.add(new ClassParser(
+								fileList[i].getPath()).parse());
+					} catch (ClassFormatException e) {
+						System.err.println("The file " + fileList[i].getPath() +
+								"ends with .class " +
+								"but cannot be interpreted as a class file.");
+						e.printStackTrace();
+					} catch (IOException e) {
+						System.err.println("IO problem(s) detected when paring " 
+								+ "the file " + fileList[i].getPath() + ".");
+						e.printStackTrace();
+					}
+				} else if (fileList[i].getPath().endsWith(".jar")) {
+					dirClasses.addAll(getJavaClassFromJar(fileList[i]));
+				}
+			} else if (fileList[i].isDirectory()) {
+				dirClasses.addAll(getJavaClassFromDir(fileList[i]));
+			}
+		}
+		return dirClasses;
+	}
+	/**
+	 * Get JavaClass object list from a jar file.
+	 * 
+	 * @param jarPath the jar file path that we get java classes from
+	 * @return the java classes we get from jarPath
+	 */
+	private Vector<JavaClass> getJavaClassFromJar(final File jarPath) {
+		Vector<JavaClass> jarClasses = new Vector<JavaClass>();
+		if (!jarPath.getPath().endsWith(".jar")) {
+			return null;
+		}
+		try {
+			JarFile jarFile = new JarFile(jarPath);
+			Enumeration<JarEntry> entries = jarFile.entries();
+			while (entries.hasMoreElements()) {
+				JarEntry entry = entries.nextElement();
+				String name = entry.getName();
+				if (name.endsWith(".class")) {
+					jarClasses.add(new ClassParser(
+							jarFile.getInputStream(entry), 
+							name.substring(name.lastIndexOf('/') + 1)).parse());
+				}
+			}
+		} catch (IOException e) {
+			System.err.println("IO problem encountered " 
+					+ "when trying to get classes from " + jarPath + ".");
+			e.printStackTrace();
+		}
+		return jarClasses;
+	}
+	
+	/**
+	 * Build class set from the class paths added before.
+	 */
+	private void buildRootClasses() {
+		Iterator<File> i = classPaths.iterator();
+		while (i.hasNext()) {
+			File classPath = i.next();
+			if (classPath.isFile()) {
+				if (classPath.getName().endsWith(".jar")) {
+					rootClasses.addAll(getJavaClassFromJar(classPath));
+				} else if (classPath.getName().endsWith(".class")) {
+					try {
+						rootClasses.add(new ClassParser(
+								classPath.getAbsolutePath()).parse());
+					} catch (ClassFormatException e) {
+						System.err.println(classPath.getAbsolutePath()  
+								+ " is not a valid class file.");
+						e.printStackTrace();
+					} catch (IOException e) {
+						System.err.println("IO problem encountered " 
+								+ "when trying to parse " 
+								+ classPath.getAbsolutePath() + ".");
+						e.printStackTrace();
+					}
+				}
+			} else if (classPath.isDirectory()) {
+				rootClasses.addAll(getJavaClassFromDir(classPath));
+			}
+		}
+		isRootClassesBuilt = true;
+	}
+	
+	/**
+	 * Build class set from the jre path set before.
+	 */
+	private void buildJreClasses() {
+		if (jrePath != null) {
+			Vector<JavaClass> jreClassList = getJavaClassFromDir(jrePath);
+			Iterator<JavaClass> i = jreClassList.iterator();
+			while (i.hasNext()) {
+				JavaClass javaClazz = i.next();
+				jreClasses.put(javaClazz.getClassName(), javaClazz);
+			}
+			isJreClassesBuilt = true;
+		}
+	}
+	
+	/**
+	 * Add a class path to class path set. A class path can be 
+	 * a file directory or a jar file.
+	 * 
+	 * @param pathName The name of the class path add to class path set
+	 */
+	public final void addClassPath(final String pathName) {
+		File newpath = new File(pathName);
+		if (newpath.exists()) {
+			classPaths.add(newpath);
+			// Root class path is modified, 
+			// set it to false to require rebuilding.
+			isRootClassesBuilt = false;
+		}
+	}
+	
+	/**
+	 * Set the path of the lib directory in JRE.
+	 * 
+	 * @param dirName The path of the lib directory in JRE
+	 */
+	public final void setJreLibPath(final String dirName) {
+		File jreDir = new File(dirName);
+		if (jreDir.exists() && jreDir.isDirectory()) {
+			jrePath = jreDir;
+			// Jre class path is modified, 
+			// set it to false to require rebuilding.
+			isJreClassesBuilt = false;
+		}
+	}
+	
+	/**
+	 * Get the dependent class set.
+	 * 
+	 * @return the dependent class set
+	 */
+	public final ClassNameSet getDependentClasses() {
+		Vector<JavaClass> workList = new Vector<JavaClass>();
+		ClassNameSet result = new ClassNameSet();
+		
+		// Build root classes and jre classes in the first time
+		// or rebuild them when they are modified.
+		if (!isRootClassesBuilt) {
+			buildRootClasses();
+		}
+		if (!isJreClassesBuilt) {
+			buildJreClasses();
+		}
+		
+		// Add basic dependency 
+		workList.addAll(rootClasses);
+		Iterator<String> keyIterator = jreClasses.keySet().iterator();
+		while (keyIterator.hasNext()) {
+			String className = keyIterator.next();
+			if (className.startsWith("java.lang.")) {
+				workList.add(jreClasses.get(className));
+				result.addName(className);
+			}
+		}
+		
+		// Traverse the worklist to decide the classes that each class depends on in the worklist.
+		// These "depended" classes are added into the worklist and result if they have not been in the result yet.
+		// The algorithm ends when the index pointer reach the end of the worklist.
+		// A dependency closure will be built with the above algorithm.
+		int i = 0;
+		while (i < workList.size()) {
+			JavaClass javaClazz = workList.elementAt(i);
+			// Get depended classes from the constant pool
+			ConstantPool cp = javaClazz.getConstantPool();
+			Constant[] carray = cp.getConstantPool();
+			for (int j = 0; j < carray.length; j++) {
+				if (carray[j] instanceof ConstantClass) {
+					int index = ((ConstantClass) carray[j]).getNameIndex();
+					String className = ((ConstantUtf8) carray[index])
+						.getBytes().replace('/', '.');
+					if (!result.isClassIn(className) 
+							&& jreClasses.containsKey(className)) {
+						workList.add(jreClasses.get(className));
+						result.addName(className);
+					}
+				}
+			}
+			// Get interfaces
+			String[] interfaceNames = javaClazz.getInterfaceNames();
+			for (int j = 0; j < interfaceNames.length; j++) {
+				if (!result.isClassIn(interfaceNames[j]) 
+						&& jreClasses.containsKey(interfaceNames[j])) {
+					workList.add(jreClasses.get(interfaceNames[j]));
+					result.addName(interfaceNames[j]);
+				}
+			}
+			// Get superclass
+			String superClassName = javaClazz.getSuperclassName();
+			if (!result.isClassIn(superClassName) 
+					&& jreClasses.containsKey(superClassName)) {
+				workList.add(jreClasses.get(superClassName));
+				result.addName(superClassName);
+			}
+			i++;
+		}
+		return result;
+	}
+	
+	/**
+	 * Get the dependent class set and write it to file.
+	 * 
+	 * @param fileName the file that will contain the dependent class set
+	 */
+	public final void getDependentClasses(final String fileName) {
+		ClassNameSet result = getDependentClasses();
+		try {
+			result.toClassListFile(fileName);
+		} catch (IOException e) {
+			System.err.println("Problem encoutered " 
+					+ "when trying to create file " 
+					+ fileName + " or write to it.");
+			e.printStackTrace();
+		}
+	}
+}

Propchange: harmony/enhanced/tools/trunk/minijre/src/org/crazynut/harmony/minjre/StaticDependencyAnalyzer.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message