[openrtm-commit:03009] r1084 - in branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src: RTMExamples_scripts rtcprof
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 12月 12日 (火) 17:40:03 JST
Author: t-katami
Date: 2017-12-12 17:40:03 +0900 (Tue, 12 Dec 2017)
New Revision: 1084
Modified:
branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcd_java
branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcd_java.sh
branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcprof_java
branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcprof_java.sh
branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/rtcprof/rtcprof.java
Log:
[merge] r1081-1083 have been merged from trunk.
Modified: branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcd_java
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcd_java 2017-12-12 02:22:09 UTC (rev 1083)
+++ branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcd_java 2017-12-12 08:40:03 UTC (rev 1084)
@@ -1,6 +1,33 @@
#!/bin/sh
+#
+# The script to start the RTC.
-if test "x$RTM_JAVA_ROOT" = "x" ; then
+#######################################
+# Gets CLASSPATH for OpenRTM
+# Arguments:
+# None
+# Returns:
+# CLASSPATH
+#######################################
+get_classpath()
+{
+ local file1
+ file1=$(ls ${RTM_JAVA_ROOT}/jar/OpenRTM*)
+ local file2
+ file2=$(ls ${RTM_JAVA_ROOT}/jar/commons-cli*)
+ local file3
+ file3=$(ls ${RTM_JAVA_ROOT}/jar/jna-?.?.?.jar)
+ local file4
+ file4=$(ls ${RTM_JAVA_ROOT}/jar/jna-platform-*.jar)
+ local file5
+ file5=$(ls ${RTM_JAVA_ROOT}/jar/rtcd.jar)
+ local class_path
+ class_path=.:${file1}:${file2}:${file3}:${file4}:${file5}:${RTM_JAVA_ROOT}/bin
+ echo ${class_path}
+}
+
+
+if test "x${RTM_JAVA_ROOT}" = "x" ; then
echo "Environment variable RTM_JAVA_ROOT is not set."
echo "Please specify the OpenRTM-aist installation directory."
echo "Abort."
@@ -7,10 +34,8 @@
exit 1
fi
-export CLASSPATH=.:$RTM_JAVA_ROOT/jar/OpenRTM-aist-1.0.0.jar:$RTM_JAVA_ROOT/jar/commons-cli-1.1.jar:$RTM_JAVA_ROOT/jar/rtcd.jar
+export CLASSPATH=$(get_classpath)
-rtcdpath=`which rtcd_java`
-#java -jar $RTM_JAVA_ROOT/jar/rtcd.jar -f $(dirname $rtcdpath)/rtcd_java.conf ${1+"$@"}
-java rtcd.rtcd -f $(dirname $rtcdpath)/rtcd_java.conf ${1+"$@"}
+java rtcd.rtcd -f ./rtcd_java.conf ${1+"$@"}
Modified: branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcd_java.sh
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcd_java.sh 2017-12-12 02:22:09 UTC (rev 1083)
+++ branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcd_java.sh 2017-12-12 08:40:03 UTC (rev 1084)
@@ -1,6 +1,33 @@
#!/bin/sh
+#
+# The script to start the RTC.
-if test "x$RTM_JAVA_ROOT" = "x" ; then
+#######################################
+# Gets CLASSPATH for OpenRTM
+# Arguments:
+# None
+# Returns:
+# CLASSPATH
+#######################################
+get_classpath()
+{
+ local file1
+ file1=$(ls ${RTM_JAVA_ROOT}/jar/OpenRTM*)
+ local file2
+ file2=$(ls ${RTM_JAVA_ROOT}/jar/commons-cli*)
+ local file3
+ file3=$(ls ${RTM_JAVA_ROOT}/jar/jna-?.?.?.jar)
+ local file4
+ file4=$(ls ${RTM_JAVA_ROOT}/jar/jna-platform-*.jar)
+ local file5
+ file5=$(ls ${RTM_JAVA_ROOT}/jar/rtcd.jar)
+ local class_path
+ class_path=.:${file1}:${file2}:${file3}:${file4}:${file5}:${RTM_JAVA_ROOT}/bin
+ echo ${class_path}
+}
+
+
+if test "x${RTM_JAVA_ROOT}" = "x" ; then
echo "Environment variable RTM_JAVA_ROOT is not set."
echo "Please specify the OpenRTM-aist installation directory."
echo "Abort."
@@ -7,8 +34,8 @@
exit 1
fi
-. ./search_classpath.func
-export CLASSPATH=`get_classpath`
-java -jar $RTM_JAVA_ROOT/jar/rtcd.jar ${1+"$@"}
+export CLASSPATH=$(get_classpath)
+java rtcd.rtcd -f ./rtcd_java.conf ${1+"$@"}
+
Modified: branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcprof_java
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcprof_java 2017-12-12 02:22:09 UTC (rev 1083)
+++ branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcprof_java 2017-12-12 08:40:03 UTC (rev 1084)
@@ -1,6 +1,30 @@
#!/bin/sh
+#
+# The shell script to get the profile of RTC.
-if test "x$RTM_JAVA_ROOT" = "x" ; then
+#######################################
+# Gets CLASSPATH for OpenRTM
+# Arguments:
+# None
+# Returns:
+# CLASSPATH
+#######################################
+get_classpath()
+{
+ local file1
+ file1=$(ls ${RTM_JAVA_ROOT}/jar/OpenRTM*)
+ local file2
+ file2=$(ls ${RTM_JAVA_ROOT}/jar/commons-cli*)
+ local file3
+ file3=$(ls ${RTM_JAVA_ROOT}/jar/jna-?.?.?.jar)
+ local file4
+ file4=$(ls ${RTM_JAVA_ROOT}/jar/jna-platform-*.jar)
+ local class_path
+ class_path=.:${file1}:${file2}:${file3}:${file4}:${RTM_JAVA_ROOT}/bin:$(dirname $0)/bin
+ echo ${class_path}
+}
+
+if test "x${RTM_JAVA_ROOT}" = "x" ; then
echo "Environment variable RTM_JAVA_ROOT is not set."
echo "Please specify the OpenRTM-aist installation directory."
echo "Abort."
@@ -7,18 +31,6 @@
exit 1
fi
-class_path=$1
-case $1 in
- *\.jar )
- class_path=$1
- ;;
- * )
- class_path=$(dirname $1)
- ;;
-esac
+export CLASSPATH=$(get_classpath)
+java -cp ${CLASSPATH}:${RTM_JAVA_ROOT}/jar/rtcprof.jar rtcprof.rtcprof ${1+"$@"}
-#export CLASSPATH=.:$RTM_JAVA_ROOT/jar/OpenRTM-aist-1.0.0.jar:$RTM_JAVA_ROOT/jar/commons-cli-1.1.jar:$(dirname $1)
-export CLASSPATH=.:$RTM_JAVA_ROOT/jar/OpenRTM-aist-1.0.0.jar:$RTM_JAVA_ROOT/jar/commons-cli-1.1.jar:$class_path
-#java -cp $CLASSPATH -jar $RTM_JAVA_ROOT/jar/rtcprof.jar ${1+"$@"}
-java -cp $CLASSPATH:$RTM_JAVA_ROOT/jar/rtcprof.jar rtcprof.rtcprof ${1+"$@"}
-
Modified: branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcprof_java.sh
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcprof_java.sh 2017-12-12 02:22:09 UTC (rev 1083)
+++ branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/RTMExamples_scripts/rtcprof_java.sh 2017-12-12 08:40:03 UTC (rev 1084)
@@ -1,6 +1,30 @@
#!/bin/sh
+#
+# The shell script to get the profile of RTC.
-if test "x$RTM_JAVA_ROOT" = "x" ; then
+#######################################
+# Gets CLASSPATH for OpenRTM
+# Arguments:
+# None
+# Returns:
+# CLASSPATH
+#######################################
+get_classpath()
+{
+ local file1
+ file1=$(ls ${RTM_JAVA_ROOT}/jar/OpenRTM*)
+ local file2
+ file2=$(ls ${RTM_JAVA_ROOT}/jar/commons-cli*)
+ local file3
+ file3=$(ls ${RTM_JAVA_ROOT}/jar/jna-?.?.?.jar)
+ local file4
+ file4=$(ls ${RTM_JAVA_ROOT}/jar/jna-platform-*.jar)
+ local class_path
+ class_path=.:${file1}:${file2}:${file3}:${file4}:${RTM_JAVA_ROOT}/bin:$(dirname $0)/bin
+ echo ${class_path}
+}
+
+if test "x${RTM_JAVA_ROOT}" = "x" ; then
echo "Environment variable RTM_JAVA_ROOT is not set."
echo "Please specify the OpenRTM-aist installation directory."
echo "Abort."
@@ -7,17 +31,6 @@
exit 1
fi
-class_path=$1
-case $1 in
- *\.jar )
- class_path=$1
- ;;
- * )
- class_path=$(dirname $1)
- ;;
-esac
+export CLASSPATH=$(get_classpath)
+java -cp ${CLASSPATH}:${RTM_JAVA_ROOT}/jar/rtcprof.jar rtcprof.rtcprof ${1+"$@"}
-. ./search_classpath.func
-export CLASSPATH=`get_classpath`:$class_path
-java -cp $CLASSPATH:$RTM_JAVA_ROOT/jar/rtcprof.jar rtcprof.rtcprof ${1+"$@"}
-
Modified: branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/rtcprof/rtcprof.java
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/rtcprof/rtcprof.java 2017-12-12 02:22:09 UTC (rev 1083)
+++ branches/RELENG_1_2/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/rtcprof/rtcprof.java 2017-12-12 08:40:03 UTC (rev 1084)
@@ -2,7 +2,9 @@
import java.util.Vector;
import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.io.File;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URLClassLoader;
import java.net.URL;
@@ -17,7 +19,6 @@
private static Class getClassFromName(String name){
String separator = System.getProperty("file.separator");
Class target = null;
-
try {
target = Class.forName(name);
} catch (java.lang.NoClassDefFoundError e) {
@@ -43,7 +44,6 @@
String name){
String separator = System.getProperty("file.separator");
Class target = null;
-
try {
target = url.loadClass(name);
} catch (java.lang.NoClassDefFoundError e) {
@@ -50,10 +50,14 @@
String messagetString = e.getMessage();
String key = "wrong name: ";
int index = messagetString.indexOf(key);
- String packageName
- = messagetString.substring(index+key.length(),
+ String packageName = new String();
+ if(index < 0){
+ packageName = messagetString;
+ }
+ else{
+ packageName = messagetString.substring(index+key.length(),
messagetString.length()-1);
-
+ }
URL[] urls = url.getURLs();
java.util.ArrayList al
= new java.util.ArrayList(java.util.Arrays.asList(urls));
@@ -112,6 +116,19 @@
return url;
}
/**
+ *
+ */
+ private static void addClassPath(ClassLoader classLoader, String path) throws ReflectiveOperationException, MalformedURLException {
+ if (classLoader instanceof URLClassLoader) {
+ // URLClassLoaderであることが前提
+ Method method =
+ URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
+ method.setAccessible(true);
+ // ロードするURLを追加する
+ method.invoke(classLoader, new File(path).toURI().toURL());
+ }
+ }
+ /**
* フルパスで指定されたコンポーネント(jarファイルとclassファイル)の
* スペックを読み込み表示する。
*
@@ -120,16 +137,26 @@
*
*/
public static void main(String[] args) {
- if (args.length != 1) {
- System.err.println("usage: ");
- if (args.length != 0) {
- System.err.println(args[0]+" .class or .jar");
- }
+ if (args.length == 0) {
+ System.err.print("usage: ");
+ System.err.println("rtcprof_java"+" <RTC>.class");
+ System.err.print(" or: ");
+ System.err.println("rtcprof_java"+" <RTCs>.jar classname");
System.err.println("");
+ System.err.println("Example:");
+ System.err.println(" rtcprof_java"+" ConsoleIn.class");
+ System.err.println(" rtcprof_java"+" bin.jar RTMExamples.SimpleIO.ConsoleIn");
+ System.err.println("");
System.exit(-1);
}
String separator = System.getProperty("file.separator");
Class target = null;
+ try{
+ args[0] = new File(args[0]).getCanonicalPath();
+ }
+ catch (Exception ex) {
+ System.out.println(ex.toString());
+ }
File file = new File(args[0]);
if(file.isAbsolute()) {
URLClassLoader url = createURLClassLoader(file.getParent());
@@ -141,7 +168,14 @@
int point = name.lastIndexOf(extensions[ic]);
name = name.substring(0, point);
if(extensions[ic].equals(".jar")){
- name = name+"."+name;
+ try{
+ addClassPath(url, args[0]);
+ if(args.length == 2){
+ name = args[1];
+ }
+ }
+ catch (Exception ex) {
+ }
}
break;
}
More information about the openrtm-commit
mailing list