diff options
-rw-r--r-- | java/lang/invoke/CallSite.java | 92 | ||||
-rw-r--r-- | java/lang/invoke/ConstantCallSite.java | 84 | ||||
-rw-r--r-- | java/lang/invoke/MethodHandle.java | 124 | ||||
-rw-r--r-- | java/lang/invoke/MethodHandleProxies.java | 64 | ||||
-rw-r--r-- | java/lang/invoke/MethodHandles.java | 253 | ||||
-rw-r--r-- | java/lang/invoke/MethodType.java | 216 | ||||
-rw-r--r-- | java/lang/invoke/MutableCallSite.java | 75 | ||||
-rw-r--r-- | java/lang/invoke/SwitchPoint.java | 59 | ||||
-rw-r--r-- | java/lang/invoke/VolatileCallSite.java | 70 | ||||
-rw-r--r-- | java/lang/invoke/WrongMethodTypeException.java | 47 | ||||
-rw-r--r-- | vm/reference/java/lang/invoke/VMCallSite.java | 47 | ||||
-rw-r--r-- | vm/reference/java/lang/invoke/VMMethodHandle.java | 52 | ||||
-rw-r--r-- | vm/reference/java/lang/invoke/VMMethodHandles.java | 61 |
13 files changed, 1244 insertions, 0 deletions
diff --git a/java/lang/invoke/CallSite.java b/java/lang/invoke/CallSite.java new file mode 100644 index 000000000..1f9153392 --- /dev/null +++ b/java/lang/invoke/CallSite.java @@ -0,0 +1,92 @@ +/* CallSite.java -- Call site for invokedynamic. + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +/** + * <code>CallSite</code> is a holder for <code>MethodHandle</code> which + * represents target method of a call-site. A call-site may be linked to zero, + * one, or multiple <code>invokedynamic</code> instructions. + * + * @since 1.7 + */ +public abstract class CallSite +{ + CallSite(MethodType type) + { + if (type == null) + throw new NullPointerException(); + + this.type = type; + } + + /** + * Returns a <code>MethodHandle</code> that is linked to this <code>CallSite</code> + * + * The returned <code>MethodHandle</code> is equivalent to a + * <code>invokedynamic</code> instruction that is linked to this + * <code>CallSite</code>. + * + * @return a <code>MethodHandle</code> that is linked to this * <code>CallSite</code> + */ + public abstract MethodHandle dynamicInvoker(); + + /** + * Returns <code>CallSite</code> target. + * @return <code>CallSite</code> target. + */ + public abstract MethodHandle getTarget(); + + /** + * Updates <code>CallSite</code> target. + * @param target new <code>CallSite</code> target. + * @throws NullPointerException if <code>target</code> is <code>null</code> + * @throws WrongMethodTypeException if <code>target</code> type does not match <code>CallSite</code> + */ + public abstract void setTarget(MethodHandle target); + + /** + * Returns <code>CallSite</code> target <code>MethodType</code>. + * @return <code>CallSite</code> target <code>MethodType</code>. + */ + public MethodType type() + { + return type; + } + + private final MethodType type; +} diff --git a/java/lang/invoke/ConstantCallSite.java b/java/lang/invoke/ConstantCallSite.java new file mode 100644 index 000000000..de273cce4 --- /dev/null +++ b/java/lang/invoke/ConstantCallSite.java @@ -0,0 +1,84 @@ +/* ConstantCallSite.java -- Constant call site for invokedynamic. + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +/** + * @since 1.7 + */ +public class ConstantCallSite + extends CallSite +{ + public ConstantCallSite(MethodHandle target) + { + super(target.type()); + + this.target = target; + } + + protected ConstantCallSite(MethodType type, MethodHandle hook) + throws Throwable + { + super(type); + + MethodHandle target = (MethodHandle) hook.invoke(this); + if (target == null) + throw new NullPointerException(); + + this.target = target; + } + + @Override public final MethodHandle dynamicInvoker() + { + return VMCallSite.dynamicInvoker(this); + } + + @Override public final MethodHandle getTarget() + { + if (target == null) + throw new IllegalStateException("constructor has not completed"); + + return target; + } + + @Override public final void setTarget(MethodHandle target) + { + throw new UnsupportedOperationException(); + } + + private final MethodHandle target; +} diff --git a/java/lang/invoke/MethodHandle.java b/java/lang/invoke/MethodHandle.java new file mode 100644 index 000000000..4e2742294 --- /dev/null +++ b/java/lang/invoke/MethodHandle.java @@ -0,0 +1,124 @@ +/* MethodHandle.java -- Method handle for invokedynamic. + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +import java.util.List; + +/** A MethodHandle is a handle to executable reference to a method, + * constructor, or field used by theinvokedynamic bytecode instruction. + * + * @since 1.7 + */ +public abstract class MethodHandle +{ + VMMethodHandle m; + + /** + * This class is uninstantiable outside this package. + */ + MethodHandle(VMMethodHandle m) + { + this.m = m; + m.m = this; + } + + public MethodHandle asCollector(Class<?> type, int len) + { + throw new UnsupportedOperationException(); + } + + public MethodHandle asFixedArity() + { + throw new UnsupportedOperationException(); + } + + public MethodHandle asSpreader(Class<?> type, int len) + { + throw new UnsupportedOperationException(); + } + + public MethodHandle asType(MethodType type) + { + throw new UnsupportedOperationException(); + } + + public MethodHandle asVarargsCollector(Class<?> type) + { + throw new UnsupportedOperationException(); + } + + public MethodHandle bindTo(Object obj) + { + throw new UnsupportedOperationException(); + } + + public final Object invoke(Object... args) throws Throwable + { + return m.invoke(args); + } + + public final Object invokeExact(Object... args) throws Throwable + { + return m.invoke(args); + } + + public Object invokeWithArguments(List<?> args) throws Throwable + { + return m.invoke(args.toArray()); + } + + public Object invokeWithArguments(Object... args) throws Throwable + { + return m.invoke(args); + } + + public boolean isVarargsCollector() + { + throw new UnsupportedOperationException(); + } + + public String toString() + { + throw new UnsupportedOperationException(); + } + + public MethodType type() + { + throw new UnsupportedOperationException(); + } +} diff --git a/java/lang/invoke/MethodHandleProxies.java b/java/lang/invoke/MethodHandleProxies.java new file mode 100644 index 000000000..e38eeb8ef --- /dev/null +++ b/java/lang/invoke/MethodHandleProxies.java @@ -0,0 +1,64 @@ +/* MethodHandleProxies.java + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +/** + * @since 1.7 + */ +public class MethodHandleProxies +{ + public static <T> T asInterfaceInstance(Class<T> type, MethodHandle target) + { + throw new UnsupportedOperationException(); + } + + public static boolean isWrapperInstance(Object obj) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle wrapperInstanceTarget(Object obj) + { + throw new UnsupportedOperationException(); + } + + public static Class<?> wrapperInstanceType(Object obj) + { + throw new UnsupportedOperationException(); + } +} diff --git a/java/lang/invoke/MethodHandles.java b/java/lang/invoke/MethodHandles.java new file mode 100644 index 000000000..74228abe9 --- /dev/null +++ b/java/lang/invoke/MethodHandles.java @@ -0,0 +1,253 @@ +/* MethodHandles.java -- Method handle helper methods. + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; + +/** + * MethodHandles contains static helper methods for method handles. + * + * @since 1.7 + */ +public class MethodHandles +{ + public static MethodHandles.Lookup lookup() + { + return new MethodHandles.Lookup(); + } + + public static MethodHandles.Lookup publicLookup() + { + return new MethodHandles.Lookup(); + } + + public static MethodHandle arrayElementGetter(Class<?> type) throws IllegalArgumentException + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle arrayElementSetter(Class<?> type) throws IllegalArgumentException + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle spreadInvoker(MethodType type, int count) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle exactInvoker(MethodType type) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle invoker(MethodType type) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle explicitCastArguments(MethodHandle target, MethodType type) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle permuteArguments(MethodHandle target, MethodType type, int... reorder) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle constant(Class<?> type, Object value) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle identity(Class<?> type) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle insertArguments(MethodHandle target, int pos, Object... values) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> types) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle dropArguments(MethodHandle target, int pos, Class<?>... types) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle filterArguments(MethodHandle target, int pos, MethodHandle... filters) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle filterReturnValue(MethodHandle target, MethodHandle filter) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle foldArguments(MethodHandle target, MethodHandle combiner) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle guardWithTest(MethodHandle test, MethodHandle target, MethodHandle fallback) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle catchException(MethodHandle target, Class<? extends Throwable> type, MethodHandle handler) + { + throw new UnsupportedOperationException(); + } + + public static MethodHandle throwException(Class<?> returnType, Class<? extends Throwable> type) + { + throw new UnsupportedOperationException(); + } + + public static final class Lookup + { + public static final int PUBLIC = 1; + public static final int PRIVATE = 2; + public static final int PROTECTED = 3; + public static final int PACKAGE = 4; + + Lookup() + { + } + + public Class<?> lookupClass() + { + throw new UnsupportedOperationException(); + } + + public int lookupModes() + { + throw new UnsupportedOperationException(); + } + + public MethodHandles.Lookup in(Class<?> type) + { + throw new UnsupportedOperationException(); + } + + public String toString() + { + throw new UnsupportedOperationException(); + } + + public MethodHandle findStatic(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException + { + return VMMethodHandles.findStatic(this, refc, name, type); + } + + public MethodHandle findVirtual(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException + { + return VMMethodHandles.findVirtual(this, refc, name, type); + } + + public MethodHandle findConstructor(Class<?> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException + { + return VMMethodHandles.findConstructor(this, refc, type); + } + + public MethodHandle findSpecial(Class<?> refc, String name, MethodType type, Class<?> specialCaller) throws NoSuchMethodException, IllegalAccessException + { + return VMMethodHandles.findSpecial(this, refc, name, type, specialCaller); + } + + public MethodHandle findGetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException + { + return VMMethodHandles.findGetter(this, refc, name, type); + } + + public MethodHandle findSetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException + { + return VMMethodHandles.findSetter(this, refc, name, type); + } + + public MethodHandle findStaticGetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException + { + return VMMethodHandles.findStaticGetter(this, refc, name, type); + } + + public MethodHandle findStaticSetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException + { + return VMMethodHandles.findStaticSetter(this, refc, name, type); + } + + public MethodHandle bind(Object obj, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException + { + throw new UnsupportedOperationException(); + } + + public MethodHandle unreflect(Method method) throws IllegalAccessException + { + throw new UnsupportedOperationException(); + } + + public MethodHandle unreflectSpecial(Method method, Class<?> specialCaller) throws IllegalAccessException + { + throw new UnsupportedOperationException(); + } + + public MethodHandle unreflectConstructor(Constructor<?> ctor) throws IllegalAccessException + { + throw new UnsupportedOperationException(); + } + + public MethodHandle unreflectGetter(Field field) throws IllegalAccessException + { + throw new UnsupportedOperationException(); + } + + public MethodHandle unreflectSetter(Field field) throws IllegalAccessException + { + throw new UnsupportedOperationException(); + } + } +} diff --git a/java/lang/invoke/MethodType.java b/java/lang/invoke/MethodType.java new file mode 100644 index 000000000..9415f8c49 --- /dev/null +++ b/java/lang/invoke/MethodType.java @@ -0,0 +1,216 @@ +/* MethodType.java -- Method handle argument and return types. + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +import java.io.Serializable; +import java.util.List; + +/** + * A MethodType represents argument and return types of method handles. + * + * @since 1.7 + */ +public final class MethodType + implements Serializable +{ + MethodType(Class<?> rtype, Class<?>[] ptypes) + { + this.rtype = rtype; + this.ptypes = ptypes; + } + + public static MethodType methodType(Class<?> rtype, Class<?>[] ptypes) + { + return new MethodType(rtype, ptypes); + } + + public static MethodType methodType(Class<?> rtype, List<Class<?>> ptypes) + { + return methodType(rtype, ptypes.toArray(new Class<?>[0])); + } + + public static MethodType methodType(Class<?> rtype, Class<?> ptype0, Class<?>... ptypes) + { + throw new UnsupportedOperationException(); + } + + public static MethodType methodType(Class<?> rtype) + { + return methodType(rtype, new Class<?>[0]); + } + + public static MethodType methodType(Class<?> rtype, Class<?> ptype0) + { + throw new UnsupportedOperationException(); + } + + public static MethodType methodType(Class<?> rtype, MethodType ptypes) + { + throw new UnsupportedOperationException(); + } + + public static MethodType genericMethodType(int paramCount, boolean lastIsArray) + { + throw new UnsupportedOperationException(); + } + + public static MethodType genericMethodType(int paramCount) + { + throw new UnsupportedOperationException(); + } + + public MethodType changeParameterType(int idx, Class<?> nptype) + { + throw new UnsupportedOperationException(); + } + + public MethodType insertParameterTypes(int idx, Class<?>... ptypes) + { + throw new UnsupportedOperationException(); + } + + public MethodType appendParameterTypes(Class<?>... ptypes) + { + throw new UnsupportedOperationException(); + } + + public MethodType insertParameterTypes(int idx, List<Class<?>> ptypes) + { + throw new UnsupportedOperationException(); + } + + public MethodType appendParameterTypes(List<Class<?>> ptypes) + { + throw new UnsupportedOperationException(); + } + + public MethodType dropParameterTypes(int start, int end) + { + throw new UnsupportedOperationException(); + } + + public MethodType changeReturnType(Class<?> type) + { + throw new UnsupportedOperationException(); + } + + public boolean hasPrimitives() + { + throw new UnsupportedOperationException(); + } + + public boolean hasWrappers() + { + throw new UnsupportedOperationException(); + } + + public MethodType erase() + { + throw new UnsupportedOperationException(); + } + + public MethodType generic() + { + throw new UnsupportedOperationException(); + } + + public MethodType wrap() + { + throw new UnsupportedOperationException(); + } + + public MethodType unwrap() + { + throw new UnsupportedOperationException(); + } + + public Class<?> parameterType(int idx) + { + throw new UnsupportedOperationException(); + } + + public int parameterCount() + { + return ptypes.length; + } + + public Class<?> returnType() + { + return rtype; + } + + public List<Class<?>> parameterList() + { + throw new UnsupportedOperationException(); + } + + public Class<?>[] parameterArray() + { + return ptypes; + } + + public boolean equals(Object object) + { + throw new UnsupportedOperationException(); + } + + public int hashCode() + { + throw new UnsupportedOperationException(); + } + + public String toString() + { + throw new UnsupportedOperationException(); + } + + public static MethodType fromMethodDescriptorString(String descriptor, ClassLoader loader) throws IllegalArgumentException, TypeNotPresentException + { + throw new UnsupportedOperationException(); + } + + public String toMethodDescriptorString() + { + throw new UnsupportedOperationException(); + } + + private final Class<?> rtype; + private final Class<?>[] ptypes; + + private static final long serialVersionUID = -1L; +} diff --git a/java/lang/invoke/MutableCallSite.java b/java/lang/invoke/MutableCallSite.java new file mode 100644 index 000000000..be85bf13d --- /dev/null +++ b/java/lang/invoke/MutableCallSite.java @@ -0,0 +1,75 @@ +/* MutableCallSite.java -- Mutable call site for invokedynamic. + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +/** + * @since 1.7 + */ +public class MutableCallSite + extends CallSite +{ + public MutableCallSite(MethodType type) + { + super(type); + } + + public MutableCallSite(MethodHandle target) + { + super(target.type()); + } + + @Override public final MethodHandle dynamicInvoker() + { + return VMCallSite.dynamicInvoker(this); + } + + @Override public final MethodHandle getTarget() + { + throw new UnsupportedOperationException(); + } + + @Override public final void setTarget(MethodHandle target) + { + throw new UnsupportedOperationException(); + } + + public static void syncAll(MutableCallSite[] sites) + { + throw new UnsupportedOperationException(); + } +} diff --git a/java/lang/invoke/SwitchPoint.java b/java/lang/invoke/SwitchPoint.java new file mode 100644 index 000000000..ee7634755 --- /dev/null +++ b/java/lang/invoke/SwitchPoint.java @@ -0,0 +1,59 @@ +/* SwitchPoint.java + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +/** + * @since 1.7 + */ +public class SwitchPoint +{ + public MethodHandle guardWithTest(MethodHandle target, MethodHandle fallback) + { + throw new UnsupportedOperationException(); + } + + public boolean hasBeenInvalidated() + { + throw new UnsupportedOperationException(); + } + + public static void invalidateAll(SwitchPoint[] switchPoints) + { + throw new UnsupportedOperationException(); + } +} diff --git a/java/lang/invoke/VolatileCallSite.java b/java/lang/invoke/VolatileCallSite.java new file mode 100644 index 000000000..c95fde3e3 --- /dev/null +++ b/java/lang/invoke/VolatileCallSite.java @@ -0,0 +1,70 @@ +/* VolatileCallSite.java -- Volatile call site for invokedynamic. + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +/** + * @since 1.7 + */ +public class VolatileCallSite + extends CallSite +{ + public VolatileCallSite(MethodType type) + { + super(type); + } + + public VolatileCallSite(MethodHandle target) + { + super(target.type()); + } + + @Override public final MethodHandle dynamicInvoker() + { + return VMCallSite.dynamicInvoker(this); + } + + @Override public final MethodHandle getTarget() + { + throw new UnsupportedOperationException(); + } + + @Override public final void setTarget(MethodHandle target) + { + throw new UnsupportedOperationException(); + } +} diff --git a/java/lang/invoke/WrongMethodTypeException.java b/java/lang/invoke/WrongMethodTypeException.java new file mode 100644 index 000000000..b62140bd3 --- /dev/null +++ b/java/lang/invoke/WrongMethodTypeException.java @@ -0,0 +1,47 @@ +/* WrongMethodTypeException.java -- + Copyright (C) 2011 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.dyn; + +/** + * @since 1.7 + */ +public class WrongMethodTypeException + extends RuntimeException +{ + private static final long serialVersionUID = -1; +} diff --git a/vm/reference/java/lang/invoke/VMCallSite.java b/vm/reference/java/lang/invoke/VMCallSite.java new file mode 100644 index 000000000..bb48ba076 --- /dev/null +++ b/vm/reference/java/lang/invoke/VMCallSite.java @@ -0,0 +1,47 @@ +/* VMCallSite.java -- + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +public final class VMCallSite +{ + private VMCallSite() + { + } + + static native MethodHandle dynamicInvoker(CallSite site); +} diff --git a/vm/reference/java/lang/invoke/VMMethodHandle.java b/vm/reference/java/lang/invoke/VMMethodHandle.java new file mode 100644 index 000000000..57dceed90 --- /dev/null +++ b/vm/reference/java/lang/invoke/VMMethodHandle.java @@ -0,0 +1,52 @@ +/* VMMethodHandle.java -- + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +public final class VMMethodHandle +{ + /** + * It is set by the constructor of MethodHandle. + */ + MethodHandle m; + + private VMMethodHandle() + { + } + + native Object invoke(Object[] args); +} diff --git a/vm/reference/java/lang/invoke/VMMethodHandles.java b/vm/reference/java/lang/invoke/VMMethodHandles.java new file mode 100644 index 000000000..c5f58965f --- /dev/null +++ b/vm/reference/java/lang/invoke/VMMethodHandles.java @@ -0,0 +1,61 @@ +/* VMMethodHandles.java -- + Copyright (C) 2011 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.invoke; + +public final class VMMethodHandles +{ + private VMMethodHandles() + { + } + + static native MethodHandle findStatic(MethodHandles.Lookup lookup, Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException; + + static native MethodHandle findVirtual(MethodHandles.Lookup lookup, Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException; + + static native MethodHandle findConstructor(MethodHandles.Lookup lookup, Class<?> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException; + + static native MethodHandle findSpecial(MethodHandles.Lookup lookup, Class<?> refc, String name, MethodType type, Class<?> specialCaller) throws NoSuchMethodException, IllegalAccessException; + + static native MethodHandle findGetter(MethodHandles.Lookup lookup, Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException; + + static native MethodHandle findSetter(MethodHandles.Lookup lookup, Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException; + + static native MethodHandle findStaticGetter(MethodHandles.Lookup lookup, Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException; + + static native MethodHandle findStaticSetter(MethodHandles.Lookup lookup, Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException; +} |