public IntPtr GetDirectBufferAddress(Object buf) { IntPtr res = getDirectBufferAddress.Invoke(envPtr, buf.jvmHandle); ExceptionTest(); return(res); }
public long GetDirectBufferCapacity(Object buf) { long res = getDirectBufferCapacity.Invoke(envPtr, buf.jvmHandle); ExceptionTest(); return(res); }
public void objectArray() { Object[] objects = new Object[3]; objects[0] = (String)"test6857"; Object[] res = testInstance.objectArray(objects); Assert.AreEqual((String)"test6857", res[1]); }
public void WrapClrString1() { Object str1 = Bridge.WrapCLR("jni4net"); string str2 = Bridge.UnwrapCLR <string>(str1); Assert.AreEqual("jni4net", str2); }
public void PrimitiveObjects() { Object integer = Bridge.WrapCLR(13); int integ = Bridge.UnwrapCLR <int>(integer); Assert.AreEqual(13, integ); }
ExpressionInfo(TypeInfo type, Object value) { this.Type = type; this.Value = value; this.IsConstant = true; this.BoxingKind = BoxingKind.None; this.Negate = true; }
public static Object StrongJ2CpObject(JNIEnv env, JniLocalHandle obj) { var res = new Object(env); ((IJvmProxy)res).Init(env, obj); return(res); }
public void CallMeFromJava() { Class testClass = env.FindClass("net/sf/jni4net/tested/JavaToClrReflection"); Object test = testClass.newInstance(); test.getClass().Invoke("reflect", "()V"); }
public void testObject() { var c = new Container(); var obj = new Object(); c.addUserData(obj); Assert.assertEquals(obj, c.getUserData(typeof(Object))); }
internal static Method GetExecuteUpdate(this Object target) { return(target .getClass() .getMethods() .Single(x => x.getName() == Constants.Methods.ExecuteUpdate && x.GetSignature() == Constants.MethodSignatures.ExecuteUpdate_String_Int)); }
public void startRound(Object aCommands, Object aStatus) { var commands = serializer.ConvertJ2C<ExecCommands>(RbSerializerN.ExecCommands_TYPE, aCommands); var status = serializer.ConvertJ2C<RobotStatus>(RbSerializerN.RobotStatus_TYPE, aStatus); domain.SetData("commands", commands); domain.SetData("status", status); domain.DoCallBack(HostingSeed.StartRound); }
public int compareTo(Object objectPar0) { var other = Bridge.UnwrapCLR<CWithJavaInterfaceUnreg>(objectPar0); if (other == null) { return -1; } return other.Value.CompareTo(Value); }
public void Wrap() { System.Text.StringBuilder builder = new System.Text.StringBuilder(); Object proxy = Bridge.WrapCLR(builder); long handle = ((IClrProxy)proxy).getClrHandle(); System.Text.StringBuilder res = Bridge.UnwrapCLR <System.Text.StringBuilder>(proxy); Assert.AreSame(builder, res); }
public void cIfaceCanInt() { var cw1 = 1; Object proxy = Bridge.WrapCLR(cw1); Class clazz = proxy.getClass(); //TODO Assert.AreEqual(System.Int32_._class, clazz); object res = Bridge.UnwrapCLR <object>(proxy); Assert.AreEqual(cw1, res); }
internal static Object PrepareStatement(this Object target, string query) { return(target.Invoke <Object>( Constants.Methods.PrepareStatement, Constants.MethodSignatures.PreparedStatement_String_PreparedStatement, new object[] { query })); }
public override bool select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IFolder) { var folder = (IFolder)element; var projectManager = Environment.getProjectManager((IResource)element); if (projectManager != null) { return !folder.getFullPath().equals(folder.getProject().getFullPath().append(projectManager.Properties.OutputPath)); } } return true; }
/// <summary> /// The buffer will be pinned and shared with java /// user is responsible for thread synchronization. /// </summary> public DirectByteBuffer(byte[] sharedBuffer, int position, int len) : base(null) { Init(); cleaner = new DirectBufferCleaner(sharedBuffer); JNIEnv env = JNIEnv.ThreadEnv; long offset = cleaner.Address.ToInt64() + position; ByteBuffer buffer; if (Bridge.Setup.BindNative && ctor != null) { // sun JVM specific Object wrap = Bridge.WrapCLR(cleaner); if (jdk6) { buffer = (ByteBuffer)env.NewObject(dbClazz, ctor, new Value { _int = len }, new Value { _long = offset }, new Value { _object = wrap.jvmHandle }); } else { buffer = (ByteBuffer)env.NewObject(dbClazz, ctor, new Value { _int = len }, new Value { _long = offset }, new Value { _object = JniHandle.Zero }, //FileDescriptor new Value { _object = wrap.jvmHandle } ); } ((IJvmProxy)wrap).JvmHandle.HoldThisHandle(); } else { // TODO ? // the buffer could disapear when collected by CLR gc buffer = env.NewDirectByteBuffer(new IntPtr(cleaner.Address.ToInt64() + position), len); } buffer.order(ByteOrder.LITTLE_ENDIAN); ((IJvmProxy)this).Copy(env, buffer.jvmHandle); }
internal static string GetString(this Object target, string columnName) { var getString = target .getClass() .getMethods() .Single(x => x.getName() == Constants.Methods.GetString && x.GetSignature() == Constants.MethodSignatures.String_String); java.lang.String result = (java.lang.String)getString.invoke(target, new[] { JNIEnv.ThreadEnv.NewString(columnName) }); return(result); }
public void jIface() { var cw1 = new CWithJavaInterface(1); var cw2 = new CWithJavaInterface(2); Object other = (Object)Bridge.WrapCLR(cw2); Assert.AreEqual(1, cw1.compareTo(other)); cw2.run(); Assert.AreEqual(3, cw2.Value); }
public void cIfaceCanString() { var cw1 = "sdfd"; Object proxy = Bridge.WrapCLR(cw1); Class clazz = proxy.getClass(); Assert.AreEqual(System.String_._class, clazz); object res = Bridge.UnwrapCLR <object>(proxy); Assert.AreSame(cw1, res); }
public void testDerivedClasses2() { var c = new Container(); var obj = new Object(); var str = "abc"; c.addUserData(str); c.addUserData(obj); Assert.assertEquals(str, c.getUserData(typeof(Object))); Assert.assertEquals("abc", c.getUserData(typeof(String))); }
public void addUserData(Object obj) { if (obj == null) { throw new IllegalArgumentException("obj"); } if (this.userData == null) { if (obj instanceof Object[]) { this.userData = new Object[] { obj }; } else { this.userData = obj; } } else if (this.userData instanceof Object[]) {
public void TypeCbyCLRProxy() { JInterfacesHelper h = new JInterfacesHelper(); CWithJavaInterface cwc = h.getCWithJavaInterfaceC(new CWithJavaInterface(0)); Object val = Bridge.WrapCLR(cwc); JniGlobalHandle jniGlobalHandle = ((IClrProxy)val).JvmHandle; RegistryRecord record = Registry.GetRecord(JNIEnv.ThreadEnv, jniGlobalHandle, val.getClass()); Assert.IsNotNull(record); jniGlobalHandle.HoldThisHandle(); }
public void testArrays2() { var c = new Container(); var obj = new Object(); var str = "abc"; var arr = new Object[] { "a", "b", "c" }; c.addUserData(arr); c.addUserData(obj); c.addUserData(str); Assert.assertEquals(arr, c.getUserData(typeof(Object))); Assert.assertEquals("abc", c.getUserData(typeof(String))); Assert.assertEquals((Object)arr, c.getUserData(typeof(Object[]))); }
public void HeavyCallMeFromJava() { var start = DateTime.Now; Class testClass = env.FindClass("net/sf/jni4net/tested/JavaToClrReflection"); Object test = testClass.newInstance(); MethodId methodId = env.GetStaticMethodID(test.getClass(), "reflect", "()V"); for (int i = 0; i < 100000; i++) { env.CallVoidMethod(test, methodId); } var end = DateTime.Now; Console.WriteLine(end - start); }
public static java.lang.Object java_Invoke_UsingSignature(this java.lang.Object liveObject, string methodName, string signature, params java.lang.Object[] methodParameters) { try { var method = (signature.isNull()) ? liveObject.getClass().getMethod(methodName, null) : liveObject.getClass().GetMethod(methodName, signature, false); var result = method.invoke(liveObject, methodParameters); return(result); } catch (System.Exception ex) { ex.log(); return(null); } }
public static TRes UnwrapCLR <TRes>(Object obj) { var clrProxy = obj as IClrProxy; if (clrProxy == null) { throw new JNIException("Can't unwrap JVM instance"); } long handle = clrProxy.getClrHandle(); object res = IntHandle.ToObject(handle); Type type = res.GetType(); Type reqType = typeof(TRes); if (!reqType.IsAssignableFrom(type)) { throw new InvalidCastException("Can't cast CLR instance of " + type + " to " + reqType); } return((TRes)res); }
public override bool select(Viewer viewer, Object parent, Object element) { if (element instanceof IFile) { var file = (IFile)element; if (!excludedFiles.contains(file)) { var extension = file.getFullPath().getFileExtension(); return "jar".equals(extension) || "zip".equals(extension); } } else if (element instanceof IContainer) { if (!recursive) { return true; } if (element instanceof IProject && !((IProject)element).isOpen()) { return false; } foreach (var member in ((IContainer)element).members()) { if (select(viewer, parent, member)) { return true; } } } return false; }
public void SetObjectArrayElement(Object array, int index, IJvmProxy val) { SetObjectArrayElement(array, index, val == null ? JniGlobalHandle.Zero : val.JvmHandle); }
public void SetObjectArrayElement(Object array, int index, JniHandle val) { SetObjectArrayElement(array.jvmHandle, index, val); }
public static bool equals(Object obj1, Object obj2) { return (obj1 == null) ? obj2 == null : obj1.equals(obj2); }
static RawAnnotationArgument buildAnnotationArgument(Object value) { if (value instanceof Integer) { return new RawSimpleValue(AnnotationArgumentKind.Int, value); } else if (value instanceof String) { return new RawSimpleValue(AnnotationArgumentKind.String, value); } else if (value instanceof Boolean) { return new RawSimpleValue(AnnotationArgumentKind.Boolean, value); } else if (value instanceof AsmType) { return new RawTypeValue((AsmType)value); } else if (value instanceof Character) { return new RawSimpleValue(AnnotationArgumentKind.Char, value); } else if (value instanceof Short) { return new RawSimpleValue(AnnotationArgumentKind.Short, value); } else if (value instanceof Long) { return new RawSimpleValue(AnnotationArgumentKind.Long, value); } else if (value instanceof Float) { return new RawSimpleValue(AnnotationArgumentKind.Float, value); } else if (value instanceof Double) { return new RawSimpleValue(AnnotationArgumentKind.Double, value); } else { var array = new RawArrayValue(); int len = Array.getLength(value); for (int i = 0; i < len; i++) { array.elements.add(buildAnnotationArgument(Array.get(value, i))); } return array; } }
static void emitFloatConstant(CodeGenerator generator, Object value) { float f = 0; if (value instanceof Float) { f = ((Float)value).floatValue(); } else if (value instanceof Long) { f = ((Long)value).longValue(); } else if (value instanceof Integer) { f = ((Integer)value).intValue(); } else if (value instanceof Character) { f = ((Character)value).charValue(); } else if (value instanceof Byte) { f = ((Byte)value).byteValue(); } else if (value instanceof Short) { f = ((Short)value).shortValue(); } if (f == 0f) { generator.emit(Opcode.Fconst_0); } else if (f == 1f) { generator.emit(Opcode.Fconst_1); } else if (f == 2f) { generator.emit(Opcode.Fconst_2); } else { generator.emit(Opcode.Ldc, Float.valueOf(f)); } }
internal static Object CreateStatement(this Object target) { return(target.Invoke <Object>(Constants.Methods.CreateStatement, Constants.MethodSignatures.CreateStatement_Statement, new object[0])); }
internal static bool Next(this Object target) { return(target.Invoke <bool>(Constants.Methods.Next, Constants.MethodSignatures.Bool, new object[0])); }
public ProjectBuildEvent(Object source) : super(source) {
internal static void Commit(this Object target) { target.Invoke(Constants.Methods.Commit, Constants.MethodSignatures.Void); }
internal PreparedStatement(java.lang.Object statement) { Contract.Requires(statement != null); _statement = statement; }
public void visit(String name, Object value) { this.method.defaultValue = buildAnnotationArgument(value); }
public void visit(String name, Object value) { annotation.arguments.put(name, buildAnnotationArgument(value)); }
public void visit(String name, Object value) { array.elements.add(buildAnnotationArgument(value)); }
public void SetObjectArrayElement(Object array, int index, JniHandle val) { SetObjectArrayElement(array.jvmHandle, index, val); }
private void SubsetFontFile(string subsetString, java.io.File paramFile1, java.io.File paramFile2) { FontFactory localFontFactory = FontFactory.getInstance(); java.io.FileInputStream localFileInputStream = null; try { localFileInputStream = new java.io.FileInputStream(paramFile1); byte[] arrayOfByte = new byte[(int)paramFile1.length()]; localFileInputStream.read(arrayOfByte); Font[] arrayOfFont = null; arrayOfFont = localFontFactory.loadFonts(arrayOfByte); Font localFont1 = arrayOfFont[0]; java.util.ArrayList localArrayList = new java.util.ArrayList(); localArrayList.add(CMapTable.CMapId.WINDOWS_BMP); //java.lang.Object localObject1 = null; java.lang.Object localObject2 = null; Font localFont2 = localFont1; java.lang.Object localObject3; if (subsetString != null) { localObject2 = new RenumberingSubsetter(localFont2, localFontFactory); ((Subsetter)localObject2).setCMaps(localArrayList, 1); localObject3 = (java.lang.Object)GlyphCoverage.getGlyphCoverage(localFont1, subsetString); ((Subsetter)localObject2).setGlyphs((java.util.List)localObject3); var localHashSet = new java.util.HashSet(); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.GDEF)); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.GPOS)); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.GSUB)); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.kern)); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.hdmx)); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.vmtx)); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.VDMX)); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.LTSH)); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.DSIG)); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.intValue(new byte[] { 109, 111, 114, 116 }))); localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.intValue(new byte[] { 109, 111, 114, 120 }))); ((Subsetter)localObject2).setRemoveTables(localHashSet); localFont2 = ((Subsetter)localObject2).subset().build(); } if (this.strip) { localObject2 = new HintStripper(localFont2, localFontFactory); localObject3 = new HashSet(); ((Set)localObject3).add(Integer.valueOf(Tag.fpgm)); ((Set)localObject3).add(Integer.valueOf(Tag.prep)); ((Set)localObject3).add(Integer.valueOf(Tag.cvt)); ((Set)localObject3).add(Integer.valueOf(Tag.hdmx)); ((Set)localObject3).add(Integer.valueOf(Tag.VDMX)); ((Set)localObject3).add(Integer.valueOf(Tag.LTSH)); ((Set)localObject3).add(Integer.valueOf(Tag.DSIG)); ((Subsetter)localObject2).setRemoveTables((Set)localObject3); localFont2 = ((Subsetter)localObject2).subset().build(); } localObject2 = new java.io.FileOutputStream(paramFile2); if (this.woff) { localObject3 = new WoffWriter().convert(localFont2); ((WritableFontData)localObject3).copyTo((OutputStream)localObject2); } else if (this.eot) { localObject3 = new EOTWriter(this.mtx).convert(localFont2); ((WritableFontData)localObject3).copyTo((OutputStream)localObject2); } else { localFontFactory.serializeFont(localFont2, (OutputStream)localObject2); } } catch (System.Exception ex) { throw new System.Exception(ex.Message); } }
public void SetObjectArrayElement(Object array, int index, IJvmProxy val) { SetObjectArrayElement(array, index, val == null ? JniGlobalHandle.Zero : val.JvmHandle); }
public void objectArray() { Object[] objects=new Object[3]; objects[0] = (String)"test6857"; Object[] res = testInstance.objectArray(objects); Assert.AreEqual((String)"test6857", res[1]); }
static void emitDoubleConstant(CodeGenerator generator, Object value) { double d = 0; if (value instanceof Double) { d = ((Double)value).doubleValue(); } else if (value instanceof Float) { d = ((Float)value).floatValue(); } else if (value instanceof Long) { d = ((Long)value).longValue(); } else if (value instanceof Integer) { d = ((Integer)value).intValue(); } else if (value instanceof Character) { d = ((Character)value).charValue(); } else if (value instanceof Byte) { d = ((Byte)value).byteValue(); } else if (value instanceof Short) { d = ((Short)value).shortValue(); } if (d == 0d) { generator.emit(Opcode.Dconst_0); } else if (d == 1d) { generator.emit(Opcode.Dconst_1); } else { generator.emit(Opcode.Ldc, Double.valueOf(d)); } }
public static java.lang.Object java_Invoke(this java.lang.Object liveObject, string methodName, params java.lang.Object[] methodParameters) { return(liveObject.java_Invoke_UsingSignature(methodName, null, methodParameters)); }
static void emitLongConstant(CodeGenerator generator, Object value) { long l = 0; if (value instanceof Long) { l = ((Long)value).longValue(); } else if (value instanceof Integer) { l = ((Integer)value).intValue(); } else if (value instanceof Character) { l = ((Character)value).charValue(); } else if (value instanceof Byte) { l = ((Byte)value).byteValue(); } else if (value instanceof Short) { l = ((Short)value).shortValue(); } if (l == 0) { generator.emit(Opcode.Lconst_0); } else if (l == 1) { generator.emit(Opcode.Lconst_1); } else { generator.emit(Opcode.Ldc, Long.valueOf(l)); } }
public static void Main() { java.lang.Object o = new java.lang.Object(); Console.WriteLine(o.hashCode()); }
static void emitIntConstant(CodeGenerator generator, Object value) { if (value instanceof Integer) { BytecodeHelper.emitIntConstant(generator, ((Integer)value).intValue()); } else if (value instanceof Character) { BytecodeHelper.emitIntConstant(generator, ((Character)value).charValue()); } else if (value instanceof Byte) { BytecodeHelper.emitIntConstant(generator, ((Byte)value).byteValue()); } else if (value instanceof Short) { BytecodeHelper.emitIntConstant(generator, ((Short)value).shortValue()); } }
internal int GetArrayLength(Object array) { return(GetArrayLength(array.jvmHandle)); }
internal static Object ExecuteQuery(this Object target) { return(target.Invoke <Object>(Constants.Methods.ExecuteQuery, Constants.MethodSignatures.ExecuteQuery_ResultSet, new object[0])); }
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { var field = new RawFieldInfo(); field.modifiers = access; field.name = name; field.value = value; classFileType.classInfo.fields.add(field); if (signature == null) { field.type = AsmType.getType(desc); } else { var parser = new SignatureParser(signature); field.signature = parser.parseFieldTypeSignature(); } fieldInfoBuilder.field = field; return fieldInfoBuilder; }
RawSimpleValue(AnnotationArgumentKind annotationArgumentKind, Object value) : super(annotationArgumentKind) {
internal int GetArrayLength(Object array) { return GetArrayLength(array.jvmHandle); }
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {}
: super(annotationArgumentKind) { this.value = value; }
ValueExpression(Class<?> type, Object value) : super(ExpressionKind.Value, type) {
public void visitLdcInsn(Object cst) {}