Build JDI support jar. am: ff9d11e469
am: afccc8cedd

Change-Id: I4142725a398526c12f1fe5b88b2c5266c25e5c18
diff --git a/Android.bp b/Android.bp
index 28e8223..56fb729 100644
--- a/Android.bp
+++ b/Android.bp
@@ -124,3 +124,47 @@
     required: ["libnpt"],
     defaults: ["upstream-jdwp-defaults"],
 }
+
+genrule {
+    name: "jdwp_generated_java",
+    tools: ["jdwpgen"],
+    cmd: "$(location jdwpgen) $(in) -jdi $(out)",
+    srcs: ["make/data/jdwp/jdwp.spec"],
+    out: ["JDWP.java"],
+}
+
+python_binary_host {
+  name: "jdi_prop_gen",
+  srcs: ["etc/jdigen.py"],
+  main: "etc/jdigen.py",
+}
+
+genrule {
+  name: "jdi_generated_properties",
+  tools: ["jdi_prop_gen"],
+  cmd: "$(location jdi_prop_gen) $(in) $(out)",
+  out: ["jdi.java"],
+  srcs: ["src/share/classes/com/sun/tools/jdi/resources/jdi.properties"],
+}
+
+// The classes needed to support JDI and debug remote processes.
+java_library_host {
+  name: "jdi-support",
+  srcs: [
+    // The JDI interface definition.
+    "src/share/classes/com/sun/jdi/**/*.java",
+    // The JDI interface implementation
+    "src/share/classes/com/sun/tools/jdi/**/*.java",
+    // The JDWP.java file that contains all the constants.
+    ":jdwp_generated_java",
+    // The properties class which holds information about the various connectors.
+    ":jdi_generated_properties",
+  ],
+  exclude_srcs: [
+    // We don't support process attachment and lack some of the classes to even compile this file.
+    "src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java",
+  ],
+  services: ["etc/com.sun.jdi.connect.Connector"],
+  javacflags: ["-g"],
+  notice: "LICENSE",
+}
\ No newline at end of file
diff --git a/etc/com.sun.jdi.connect.Connector b/etc/com.sun.jdi.connect.Connector
new file mode 100644
index 0000000..01de058
--- /dev/null
+++ b/etc/com.sun.jdi.connect.Connector
@@ -0,0 +1,2 @@
+com.sun.tools.jdi.SocketAttachingConnector
+com.sun.tools.jdi.SocketListeningConnector
\ No newline at end of file
diff --git a/etc/jdigen.py b/etc/jdigen.py
new file mode 100644
index 0000000..a5ba1a5
--- /dev/null
+++ b/etc/jdigen.py
@@ -0,0 +1,60 @@
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed 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.
+#
+
+from __future__ import print_function
+import sys
+
+args = sys.argv
+
+if len(args) != 3:
+  print("Usage: jdigen <input> <output>")
+  sys.exit(1)
+
+TEMPLATE = """
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed 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.
+
+package com.sun.tools.jdi.resources;
+import java.util.ListResourceBundle;
+public final class jdi extends ListResourceBundle {{
+  protected final Object[][] getContents() {{
+    return new Object[][] {{
+      {values}
+    }};
+  }}
+}}
+"""
+
+INSTANCE_FORMAT = '{{ "{key}", "{value}" }},\n'
+
+VALUES = ""
+with open(args[1], 'r+') as inp:
+  for l in inp.readlines():
+    key, value = l.split('=')
+    VALUES += INSTANCE_FORMAT.format(key = key.strip(), value = value.strip())
+
+with open(args[2], 'w') as out:
+  out.write(TEMPLATE.format(values = VALUES))