You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2007/05/16 21:06:12 UTC
svn commit: r538688 - in /harmony/enhanced/jdktools/trunk: make/
modules/jpda/ modules/jpda/META-INF/ modules/jpda/make/
modules/jpda/src/main/java/ modules/jpda/src/main/java/org/
modules/jpda/src/main/java/org/eclipse/ modules/jpda/src/main/java/org/...
Author: gshimansky
Date: Wed May 16 12:06:11 2007
New Revision: 538688
URL: http://svn.apache.org/viewvc?view=rev&rev=538688
Log:
Applied HARMONY-3210 [netbeans] JDI implementation is missing
Added:
harmony/enhanced/jdktools/trunk/modules/jpda/META-INF/
harmony/enhanced/jdktools/trunk/modules/jpda/META-INF/MANIFEST.MF (with props)
harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/
harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/org/
harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/org/eclipse/
harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/org/eclipse/osgi/
harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/org/eclipse/osgi/util/
harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/org/eclipse/osgi/util/NLS.java (with props)
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/com/sun/jdi/
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/com/sun/jdi/Bootstrap.java (with props)
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.java (with props)
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.properties (with props)
Modified:
harmony/enhanced/jdktools/trunk/make/depends.properties
harmony/enhanced/jdktools/trunk/make/depends.xml
harmony/enhanced/jdktools/trunk/modules/jpda/build.xml
harmony/enhanced/jdktools/trunk/modules/jpda/make/hyproperties.xml
harmony/enhanced/jdktools/trunk/modules/tools/META-INF/MANIFEST.MF
harmony/enhanced/jdktools/trunk/modules/tools/build.xml
harmony/enhanced/jdktools/trunk/modules/tools/make/hyproperties.xml
Modified: harmony/enhanced/jdktools/trunk/make/depends.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/make/depends.properties?view=diff&rev=538688&r1=538687&r2=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/make/depends.properties (original)
+++ harmony/enhanced/jdktools/trunk/make/depends.properties Wed May 16 12:06:11 2007
@@ -22,6 +22,22 @@
ecj.url=http://download.eclipse.org/eclipse/downloads/drops/S-3.3M7-200705031400/ecj.jar
ecj.md5=23d38c997a6a0d47586965f7505bed67
+icu.dir=${depends.jars}/com.ibm.icu.base-3.3M7
+icu.zip=${icu.dir}/com.ibm.icu.base-3.3M7.zip
+icu.url=http://download.eclipse.org/eclipse/downloads/drops/S-3.3M7-200705031400/com.ibm.icu.base-3.3M7.zip
+icu.md5=e1c39bbc93ed2f4b03fddb3c5418f4ee
+icu.jar.name=com.ibm.icu.base_3.6.1.v20070417.jar
+icu.jar=${icu.dir}/${icu.jar.name}
+
+jdt.dir=${depends.jars}/eclipse-JDT-3.3M7
+jdt.zip=${jdt.dir}/eclipse-JDT-3.3M7.zip
+jdt.url=http://download.eclipse.org/eclipse/downloads/drops/S-3.3M7-200705031400/eclipse-JDT-3.3M7.zip
+jdt.md5=d26e1a0097ba81059df720ffd613dbb8
+jdt.jdi.jar.name=jdi.jar
+jdt.jdi.jar=${jdt.dir}/${jdt.jdi.jar.name}
+jdt.jdimodel.jar.name=jdimodel.jar
+jdt.jdimodel.jar=${jdt.dir}/${jdt.jdimodel.jar.name}
+
junit.dir=${depends.jars}/junit_3.8.2
junit.jar=${junit.dir}/junit.jar
junit.url=${mirror.base}/junit/junit/3.8.2/junit-3.8.2.jar
Modified: harmony/enhanced/jdktools/trunk/make/depends.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/make/depends.xml?view=diff&rev=538688&r1=538687&r2=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/make/depends.xml (original)
+++ harmony/enhanced/jdktools/trunk/make/depends.xml Wed May 16 12:06:11 2007
@@ -37,7 +37,7 @@
</target>
<target name="download" description="Download required jars"
- depends="-download" />
+ depends="-download,-extract" />
<target name="-download">
@@ -45,12 +45,54 @@
<download-one-file src="${ecj.url}" dest="${ecj.jar}"
md5="${ecj.md5}" />
+ <mkdir dir="${icu.dir}" />
+ <download-one-file src="${icu.url}" dest="${icu.zip}"
+ md5="${icu.md5}" />
+
+ <mkdir dir="${jdt.dir}" />
+ <download-one-file src="${jdt.url}" dest="${jdt.zip}"
+ md5="${jdt.md5}" />
+
<mkdir dir="${junit.dir}" />
<download-one-file src="${junit.url}" dest="${junit.jar}"
md5="${junit.md5}" />
</target>
+ <target name="-extract" depends="-extract-props,-really-extract" />
+ <target name="-extract-props" depends="-extract-props-icu,-extract-props-jdt"/>
+ <target name="-really-extract" depends="-really-extract-icu,-really-extract-jdt"/>
+
+ <target name="-extract-props-icu">
+ <uptodate property="icu.uptodate"
+ srcfile="${icu.zip}"
+ targetfile="${icu.jar}" />
+ </target>
+ <target name="-extract-props-jdt">
+ <uptodate property="jdt.uptodate"
+ srcfile="${jdt.zip}"
+ targetfile="${jdt.jdi.jar}" />
+ </target>
+
+ <target name="-really-extract-icu" unless="icu.uptodate">
+ <unzip src="${icu.zip}" dest="${icu.dir}.tmp" />
+ <copy todir="${icu.dir}" flatten="yes">
+ <fileset dir="${icu.dir}.tmp/eclipse/plugins">
+ <include name="com.ibm.icu.base_*.jar"/>
+ </fileset>
+ </copy>
+ <delete dir="${icu.dir}.tmp" />
+ </target>
+ <target name="-really-extract-jdt" unless="jdt.uptodate">
+ <unzip src="${jdt.zip}" dest="${jdt.dir}.tmp" />
+ <copy todir="${jdt.dir}" flatten="yes">
+ <fileset dir="${jdt.dir}.tmp/eclipse/plugins">
+ <include name="org.eclipse.jdt.debug_*/jdi.jar"/>
+ <include name="org.eclipse.jdt.debug_*/jdimodel.jar"/>
+ </fileset>
+ </copy>
+ <delete dir="${jdt.dir}.tmp" />
+ </target>
<macrodef name="download-one-file">
<attribute name="src" />
Added: harmony/enhanced/jdktools/trunk/modules/jpda/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/META-INF/MANIFEST.MF?view=auto&rev=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/META-INF/MANIFEST.MF (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/META-INF/MANIFEST.MF Wed May 16 12:06:11 2007
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Specification-Title: Java Platform API Specification
+Specification-Version: 1.5
+Implementation-Title: Apache Harmony
+Implementation-Vendor: The Apache Software Foundation
+Implementation-Vendor-Id: org.apache.harmony
+Implementation-URL: http://incubator.apache.org/harmony
+Bundle-ManifestVersion: 2
+Bundle-Name: Harmony JPDA
+Bundle-SymbolicName: org.apache.harmony.jpda
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Eclipse-JREBundle: true
+Import-Package: java.lang,
+ java.util,
+Export-Package: org.eclipse.osgi.util
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
svn:eol-style = native
Modified: harmony/enhanced/jdktools/trunk/modules/jpda/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/build.xml?view=diff&rev=538688&r1=538687&r2=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/build.xml (original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/build.xml Wed May 16 12:06:11 2007
@@ -30,6 +30,17 @@
<!-- filename for tests exclude list -->
<property name="jpda.exclude.file" location="${hy.hdk}/build/jdktools.jpda.exclude" />
+ <fileset id="classes" dir="${hy.build}">
+ <or>
+ <present targetdir="${hy.jpda.src.main.java}" />
+ <present targetdir="${hy.jpda.src.main.java}">
+ <mapper type="regexp"
+ from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
+ to="\1.java"/>
+ </present>
+ </or>
+ </fileset>
+
<property file="../../make/depends.properties" />
<target name="build" depends="build-java, build-native" />
@@ -48,7 +59,66 @@
</target>
<!-- Build Java code -->
- <target name="build-java"/>
+ <target name="build-java" depends="compile-java, build-jar, copy-jars" />
+
+ <target name="compile-java">
+ <echo message="Compiling JPDA classes" />
+
+ <mkdir dir="${hy.build}" />
+ <mkdir dir="${hy.jdk}/lib" />
+
+ <javac sourcepath=""
+ srcdir="${hy.jpda.src.main.java}"
+ destdir="${hy.build}"
+ compiler="${hy.javac.compiler}"
+ memoryMaximumSize="${hy.javac.maxmem}"
+ source="${hy.javac.source}"
+ target="${hy.javac.target}"
+ debug="${hy.javac.debug}">
+
+ <classpath>
+ <pathelement path="${jdt.jdi.jar}"/>
+ <pathelement path="${jdt.jdimodel.jar}"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <!-- create jdtstub.jar to resolve JDI implementation dependency -->
+ <target name="build-jar" depends="svn-info">
+ <mkdir dir="${hy.jdk}/lib" />
+
+ <jar destfile="${hy.jdk}/lib/jdtstub.jar"
+ manifest="${hy.jpda}/META-INF/MANIFEST.MF">
+
+ <fileset refid="classes" />
+
+ <manifest>
+ <attribute name="Implementation-Version" value="${svn.info}"/>
+ </manifest>
+
+ <metainf file="${hy.hdk}/NOTICE"/>
+ <metainf file="${hy.hdk}/LICENSE"/>
+ </jar>
+
+ <jar destfile="${hy.jdk}/lib/jdtstub-src.jar">
+ <fileset dir="${hy.jpda.src.main.java}" />
+ <manifest>
+ <attribute name="Implementation-Version" value="${svn.info}"/>
+ </manifest>
+
+ <metainf file="${hy.hdk}/NOTICE"/>
+ <metainf file="${hy.hdk}/LICENSE"/>
+ </jar>
+ </target>
+
+ <!-- copy all required jars with JDI implementation and dependent classes -->
+ <target name="copy-jars">
+ <mkdir dir="${hy.jdk}/lib" />
+ <copy todir="${hy.jdk}/lib" flatten="true">
+ <fileset file="${icu.jar}"/>
+ <fileset file="${jdt.jdimodel.jar}"/>
+ </copy>
+ </target>
<!-- Build native code -->
<target name="build-native">
@@ -74,7 +144,21 @@
<target name="test-module" depends="build-tests, prepare-exclude, run-tests" />
<!-- Clean Java -->
- <target name="clean-java"/>
+ <target name="clean-java">
+ <echo message="Cleaning JPDA classes" />
+
+ <delete file="${hy.jdk}/lib/jdtstub.jar" />
+ <delete file="${hy.jdk}/lib/jdtstub-src.jar" />
+
+ <delete file="${hy.jdk}/lib/${icu.jar.name}" />
+ <delete file="${hy.jdk}/lib/${jdt.jdimodel.jar.name}" />
+
+ <delete includeemptydirs="true" failonerror="false">
+ <!--fileset refid="classes" /-->
+ <fileset dir="${hy.build}" />
+ <fileset dir="${tests.build.output}/classes" />
+ </delete>
+ </target>
<!-- Clean natives -->
<target name="clean-native">
Modified: harmony/enhanced/jdktools/trunk/modules/jpda/make/hyproperties.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/make/hyproperties.xml?view=diff&rev=538688&r1=538687&r2=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/make/hyproperties.xml (original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/make/hyproperties.xml Wed May 16 12:06:11 2007
@@ -36,7 +36,7 @@
<test location="bin/test" />
</bin>
<packaging>
- <jarname>jpda</jarname>
+ <jarname>jdtstub</jarname>
</packaging>
</jpda>
Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/org/eclipse/osgi/util/NLS.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/org/eclipse/osgi/util/NLS.java?view=auto&rev=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/org/eclipse/osgi/util/NLS.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/org/eclipse/osgi/util/NLS.java Wed May 16 12:06:11 2007
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Ivan Popov
+* @version $Revision$
+*/
+
+package org.eclipse.osgi.util;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This stub class replaces org.eclipse.osgi.util.NLS from Eclipse RCP bundle and provides
+ * only NLS functionality required for JDI implementation.
+ */
+public class NLS {
+
+ /**
+ * Fills given field with corresponding resource string from given resource bundle.
+ * If bundle is null or corresponding resource string is not found, then
+ * field name will be assigned to the field.
+ *
+ * @param field - static field to assign resource string to
+ * @param bundle - resource bundle where to find resource string or null
+ */
+ private static void fillFieldValue(Field field, ResourceBundle bundle) {
+ String name = field.getName();
+ String value = null;
+ if (bundle != null) {
+ try {
+ value = bundle.getString(name);
+ } catch (MissingResourceException e) {
+ // ignore
+ e.printStackTrace(); // TODO: remove
+ }
+ }
+ if (value == null) {
+ value = name;
+ }
+ try {
+ field.set(null, value);
+ } catch (Exception e) {
+ // ignore
+ e.printStackTrace(); // TODO: remove
+ }
+ }
+
+ /**
+ * Loads localized messages from given bundle and assigns them to corresponding
+ * static fields of given class.
+ *
+ * @param bundleName - name of resource bundle to load messages from
+ * @param cls - Class instance whose static fields will be filled with appropriate messages
+ */
+ public static void initializeMessages(String bundleName, Class cls) {
+ ClassLoader loader = cls.getClassLoader();
+ Field[] fields = cls.getDeclaredFields();
+
+ // load bundle for specified class
+ ResourceBundle bundle = null;
+ try {
+ Locale locale = Locale.getDefault();
+ bundle = ResourceBundle.getBundle(bundleName, locale, loader);
+ } catch (MissingResourceException e) {
+ // ignore
+ e.printStackTrace(); // TODO: remove
+ }
+
+ // fill appropriate class fields with strings from resource bundle
+ for (int i = 0; i < fields.length; i++) {
+ Field field = fields[i];
+ // only fields declared in given class
+ if (field.getDeclaringClass() == cls) {
+ // only public static and not final fields
+ int modifiers = field.getModifiers();
+ if ((modifiers & Modifier.FINAL) == 0
+ && (modifiers & Modifier.STATIC) != 0
+ && (modifiers & Modifier.PUBLIC) != 0) {
+ fillFieldValue(fields[i], bundle);
+ }
+ }
+ }
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/main/java/org/eclipse/osgi/util/NLS.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: harmony/enhanced/jdktools/trunk/modules/tools/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/META-INF/MANIFEST.MF?view=diff&rev=538688&r1=538687&r2=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/META-INF/MANIFEST.MF Wed May 16 12:06:11 2007
@@ -34,4 +34,11 @@
org.apache.harmony.security.x501;version="1.0.0",
org.apache.harmony.security.x509;version="1.0.0"
Export-Package: org.apache.harmony.tools.javac,
- org.apache.harmony.tools.keytool
+ org.apache.harmony.tools.javah,
+ org.apache.harmony.tools.jarsigner,
+ org.apache.harmony.tools.keytool,
+ com.sun.tools.javac,
+ com.sun.tools.jdi,
+ com.sun.tools.jdi.connect,
+ com.sun.tools.jdi.event,
+ com.sun.tools.jdi.request
Modified: harmony/enhanced/jdktools/trunk/modules/tools/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/build.xml?view=diff&rev=538688&r1=538687&r2=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/build.xml (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/build.xml Wed May 16 12:06:11 2007
@@ -98,6 +98,10 @@
<include name="**/*.jar" />
</fileset>
</bootclasspath>
+
+ <classpath>
+ <pathelement path="${jdt.jdi.jar}"/>
+ </classpath>
</javac>
</target>
@@ -115,7 +119,13 @@
<jar destfile="${hy.jdk}/lib/tools.jar"
manifest="${hy.tools}/META-INF/MANIFEST.MF">
+
<fileset refid="classes" />
+ <zipfileset src="${jdt.jdi.jar}">
+ <exclude name="com/sun/jdi/Bootstrap.class"/>
+ <exclude name="META-INF/*"/>
+ </zipfileset>
+
<manifest>
<attribute name="Implementation-Version" value="${svn.info}"/>
</manifest>
Modified: harmony/enhanced/jdktools/trunk/modules/tools/make/hyproperties.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/make/hyproperties.xml?view=diff&rev=538688&r1=538687&r2=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/make/hyproperties.xml (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/make/hyproperties.xml Wed May 16 12:06:11 2007
@@ -34,6 +34,7 @@
<test location="bin/test" />
</bin>
<packaging>
+ <jarname>tools</jarname>
</packaging>
</tools>
Added: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/com/sun/jdi/Bootstrap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/com/sun/jdi/Bootstrap.java?view=auto&rev=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/com/sun/jdi/Bootstrap.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/com/sun/jdi/Bootstrap.java Wed May 16 12:06:11 2007
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Ivan Popov
+* @version $Revision$
+*/
+
+package com.sun.jdi;
+
+import com.sun.jdi.VirtualMachineManager;
+
+/**
+ * This class is for replacing corresponding empty class in JDI API provided by Eclipse JDT,
+ * it works as a wrapper for @link org.apache.harmony.tools.internal.jdi.Bootstrap.
+ */
+public class Bootstrap {
+
+ /**
+ * Redirects initialization of JDI implementation to
+ * @link org.apache.harmony.tools.internal.jdi.Bootstrap#virtualMachineManager().
+ *
+ * @return instance of VirtualMachineManager created by JDI implementation
+ */
+ static public VirtualMachineManager virtualMachineManager() {
+ return org.apache.harmony.tools.internal.jdi.Bootstrap.virtualMachineManager();
+ }
+
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/com/sun/jdi/Bootstrap.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.java?view=auto&rev=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.java Wed May 16 12:06:11 2007
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* @author Ivan Popov
+* @version $Revision$
+*/
+
+package org.apache.harmony.tools.internal.jdi;
+
+import com.sun.jdi.VirtualMachineManager;
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This class is a proxy for JDI bootstrap implementation.
+ *
+ * It looks for corresponding jars with JDI implementation, loads appropriate bootstrap class
+ * and redirects initialization to it. Details of the used JDI implementation are specified in
+ * Bootstrap.properties file.
+ */
+public class Bootstrap {
+
+ /**
+ * Default name for JDI properties bundle.
+ */
+ public static final String BUNDLE_JDI_NAME = "org.apache.harmony.tools.internal.jdi.Bootstrap";
+
+ /**
+ * Property to specify name of JDI Bootstrap class.
+ */
+ public static final String PROPERTY_JDI_BOOTSTRAP = "org.apache.harmony.tools.jdi.bootstrap";
+
+ /**
+ * Property to specify location of jars with JDI implementation.
+ */
+ public static final String PROPERTY_JDI_LOCATION = "org.apache.harmony.tools.jdi.location";
+
+ /**
+ * Property prefix to specify name of jars with JDI implementation.
+ */
+ public static final String PROPERTY_JDI_JAR = "org.apache.harmony.tools.jdi.jar.";
+
+ /**
+ * Loads JDI implementation from corresponding jars and redirects initialization to
+ * its Bootstrap class.
+ *
+ * @return instance of VirtualMachineManager created by JDI implementation
+ * @throw RuntimeException if there is any problem in locating and loading JDI implementation
+ */
+ static public VirtualMachineManager virtualMachineManager() {
+ if (vmm == null) {
+ String bootstrapName = null;
+ String baseDir = null;
+ try {
+ // load resource bundle with JDI implementation properties
+ ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_JDI_NAME);
+
+ // read JDI properties from resource bundle
+ bootstrapName = bundle.getString(PROPERTY_JDI_BOOTSTRAP);
+
+ try {
+ baseDir = bundle.getString(PROPERTY_JDI_LOCATION);
+ } catch (MissingResourceException e) {
+ // ignore exception and use default location
+ baseDir = System.getProperty("java.home") + "/../lib";
+ }
+
+ ArrayList urls = new ArrayList();
+ try {
+ for (int i = 0; ; i++) {
+ String key = PROPERTY_JDI_JAR + i;
+ String jar = bundle.getString(key);
+ URL url = new URL("file", null, baseDir + "/" + jar);
+ urls.add(url);
+ }
+ } catch (MissingResourceException e) {
+ // ignore exception and finish reading jar entries
+ }
+
+ // create class loader for JDI implementation
+ URL buf[] = new URL[urls.size()];
+ ClassLoader loader = new URLClassLoader((URL[])(urls.toArray(buf)));
+
+ // load and initialize JDI bootsrap
+ Class cls = Class.forName(bootstrapName, true, loader);
+ java.lang.reflect.Method method = cls.getMethod("virtualMachineManager", null);
+ vmm = (VirtualMachineManager)method.invoke(null, null);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot initialize JDI bootstrap: " + bootstrapName, e);
+ }
+ }
+ return vmm;
+ }
+
+ static private VirtualMachineManager vmm = null;
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.properties?view=auto&rev=538688
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.properties (added)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.properties Wed May 16 12:06:11 2007
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Fully qualified class name for JDI Bootstrap implementation.
+org.apache.harmony.tools.jdi.bootstrap=org.eclipse.jdi.Bootstrap
+
+# Location of jar files with JDI implementation.
+# Default location is jdk/lib directory, redefine it if necessary.
+#org.apache.harmony.tools.jdi.location=${java.home}/../lib
+
+# Ordered list of jar files with JDI implementation.
+org.apache.harmony.tools.jdi.jar.0=jdtstub.jar
+org.apache.harmony.tools.jdi.jar.1=jdimodel.jar
+org.apache.harmony.tools.jdi.jar.2=com.ibm.icu.base_3.6.1.v20070417.jar
Propchange: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/internal/jdi/Bootstrap.properties
------------------------------------------------------------------------------
svn:eol-style = native