[1] Updates to project files and a test for invoking against null.
- From: headius@kenai.com
- To: commits@invoke-dynamic-tests.kenai.com
- Subject: [1] Updates to project files and a test for invoking against null.
- Date: Thu, 11 Sep 2008 21:13:06 +0000 (GMT)
Revision: 1
Author: cnutter
Date: 2008-09-11 20:53:04 UTC
Log Message:
-----------
Updates to project files and a test for invoking against null.
Modified Paths:
--------------
nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/private/private.properties
Added Paths:
-----------
src/com/sun/dynamic/test/DynamicAgainstNull.java
Diffs:
-----
diff -r 8494b5109283 -r e87a17f48516 nbproject/build-impl.xml
--- a/nbproject/build-impl.xml Sat Sep 06 01:48:32 2008 -0500
+++ b/nbproject/build-impl.xml Thu Sep 11 15:53:04 2008 -0500
@@ -218,13 +218,13 @@
</sequential>
</macrodef>
</target>
- <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
+ <target name="-init-macrodef-nbjpda">
<macrodef name="nbjpdastart"
uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute default="${main.class}" name="name"/>
<attribute default="${debug.classpath}" name="classpath"/>
<attribute default="" name="stopclassname"/>
<sequential>
- <nbjpdastart addressproperty="jpda.address"
name="@{name}" stopclassname="@{stopclassname}"
transport="${debug-transport}">
+ <nbjpdastart addressproperty="jpda.address"
name="@{name}" stopclassname="@{stopclassname}" transport="dt_socket">
<classpath>
<path path="@{classpath}"/>
</classpath>
@@ -255,12 +255,6 @@
<condition else="-Xdebug" property="debug-args-line"
value="-Xdebug -Xnoagent -Djava.compiler=none">
<istrue value="${have-jdk-older-than-1.4}"/>
</condition>
- <condition else="dt_socket" property="debug-transport-by-os"
value="dt_shmem">
- <os family="windows"/>
- </condition>
- <condition else="${debug-transport-by-os}"
property="debug-transport" value="${debug.transport}">
- <isset property="debug.transport"/>
- </condition>
</target>
<target depends="-init-debug-args" name="-init-macrodef-debug">
<macrodef name="debug"
uri="http://www.netbeans.org/ns/j2se-project/3">
@@ -270,7 +264,7 @@
<sequential>
<java classname="@{classname}" dir="${work.dir}"
fork="true">
<jvmarg line="${debug-args-line}"/>
- <jvmarg
value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/
>
+ <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
<jvmarg line="${run.jvmargs}"/>
<classpath>
<path path="@{classpath}"/>
@@ -317,13 +311,6 @@
===================
-->
<target depends="init" name="deps-jar" unless="no.deps"/>
- <target
depends="init,-check-automatic-build,-clean-after-automatic-build"
name="-verify-automatic-build"/>
- <target depends="init" name="-check-automatic-build">
- <available
file="${build.classes.dir}/.netbeans_automatic_build"
property="netbeans.automatic.build"/>
- </target>
- <target depends="init" if="netbeans.automatic.build"
name="-clean-after-automatic-build">
- <antcall target="clean"/>
- </target>
<target depends="init,deps-jar" name="-pre-pre-compile">
<mkdir dir="${build.classes.dir}"/>
</target>
@@ -344,7 +331,7 @@
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file.
-->
</target>
- <target
depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-co
mpile,-do-compile,-post-compile" description="Compile project."
name="compile"/>
+ <target
depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-
compile" description="Compile project." name="compile"/>
<target name="-pre-compile-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file.
-->
diff -r 8494b5109283 -r e87a17f48516 nbproject/genfiles.properties
--- a/nbproject/genfiles.properties Sat Sep 06 01:48:32 2008 -0500
+++ b/nbproject/genfiles.properties Thu Sep 11 15:53:04 2008 -0500
@@ -4,5 +4,5 @@
# This file is used by a NetBeans-based IDE to track changes in
generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never
regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=f1bb7647
-nbproject/build-impl.xml.script.CRC32=35e364ab
-nbproject/build-impl.xml.stylesheet.CRC32=61b4e419
+nbproject/build-impl.xml.script.CRC32=35d1d749
+nbproject/build-impl.xml.stylesheet.CRC32=487672f9
diff -r 8494b5109283 -r e87a17f48516
nbproject/private/private.properties
--- a/nbproject/private/private.properties Sat Sep 06 01:48:32
2008 -0500
+++ b/nbproject/private/private.properties Thu Sep 11 15:53:04
2008 -0500
@@ -3,4 +3,4 @@
do.jar=true
javac.debug=true
javadoc.preview=true
-user.properties.file=/Users/headius/.netbeans/6.5beta/build.properties
+user.properties.file=/Users/headius/.netbeans/6.1/build.properties
diff -r 8494b5109283 -r e87a17f48516
src/com/sun/dynamic/test/DynamicAgainstNull.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/sun/dynamic/test/DynamicAgainstNull.java Thu Sep 11
15:53:04 2008 -0500
@@ -0,0 +1,87 @@
+package com.sun.dynamic.test;
+
+import java.dyn.AnonymousClassLoader;
+import java.dyn.CallSite;
+import java.dyn.ConstantPoolPatch;
+import java.dyn.Dynamic;
+import java.dyn.InvalidConstantPoolFormatException;
+import java.dyn.Linkage;
+import java.dyn.MethodHandle;
+import java.dyn.MethodHandles;
+import java.dyn.MethodType;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.regex.Pattern;
+
+public class DynamicAgainstNull {
+ public static void main(String[] args) {
+ try {
+ InvokerIfc invoker =
(InvokerIfc)rewrite(Invoker.class).newInstance();
+ invoker.doit(1);
+ invoker.doit(1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static class Something {}
+
+ public static Object target(Object obj, Integer b) {
+ System.out.println("obj is " + obj + ", integer is " + b);
+ return null;
+ }
+
+ public static Object bootstrap(CallSite site, Object... args) {
+ MethodHandle target = MethodHandles.findStatic(
+ DynamicAgainstNull.class,
+ "target",
+ MethodType.make(Object.class, String.class,
site.type().parameterArray()));
+ site.setTarget(target);
+
+ return target(args[0], (Integer)args[1]);
+ }
+
+ public interface Target {
+ public Object target(Integer b);
+ }
+ public static Target fake(Object obj) {
+ return (Target)obj;
+ }
+ public static Object real(Object obj) {
+ return obj;
+ }
+
+ public interface InvokerIfc {
+ public Object doit(Integer b);
+ }
+
+ public static class Invoker implements InvokerIfc {
+ public Object doit(Integer b) {
+ return fake(null).target(b);
+ }
+
+ static {
+ Linkage.registerBootstrapMethod(
+ Invoker.class,
+ MethodHandles.findStatic(DynamicAgainstNull.class,
"bootstrap", Linkage.BOOTSTRAP_METHOD_TYPE));
+ }
+ }
+
+ public static Class rewrite(Class old) throws IOException,
InvalidConstantPoolFormatException {
+ final HashMap<String,String> utf8Map = new
HashMap<String,String>();
+ utf8Map.put("fake", "real");
+ String objbcn = Object.class.getName().replace('.', '/');
+ String objsig = "L"+objbcn+";";
+ String fdbcn = Target.class.getName().replace('.', '/');
+ String rdbcn = Dynamic.class.getName().replace('.', '/');
+ utf8Map.put(fdbcn, rdbcn);
+ String fakesig = "("+objsig+")L"+fdbcn+";";
+ utf8Map.put(fakesig, fakesig.replaceAll(Pattern.quote(fdbcn),
objbcn));
+ final ConstantPoolPatch patch = new
ConstantPoolPatch(Invoker.class);
+ patch.putPatches(utf8Map, null, null, true);
+ if (!utf8Map.isEmpty())
+ throw new AssertionError("Map not empty: "+utf8Map);
+ return new
AnonymousClassLoader(Invoker.class).loadClass(patch);
+ }
+}
|
[1] Updates to project files and a test for invoking against null. |
headius | 09/11/2008 |





