예제 #1
0
파일: JNIEnv.cs 프로젝트: cd37ycs/jni4net
        public IntPtr GetDirectBufferAddress(Object buf)
        {
            IntPtr res = getDirectBufferAddress.Invoke(envPtr, buf.jvmHandle);

            ExceptionTest();
            return(res);
        }
예제 #2
0
파일: JNIEnv.cs 프로젝트: cd37ycs/jni4net
        public long GetDirectBufferCapacity(Object buf)
        {
            long res = getDirectBufferCapacity.Invoke(envPtr, buf.jvmHandle);

            ExceptionTest();
            return(res);
        }
예제 #3
0
 public void objectArray()
 {
     Object[] objects = new Object[3];
     objects[0] = (String)"test6857";
     Object[] res = testInstance.objectArray(objects);
     Assert.AreEqual((String)"test6857", res[1]);
 }
예제 #4
0
파일: BasicTests.cs 프로젝트: gywerd/WinJNI
        public void WrapClrString1()
        {
            Object str1 = Bridge.WrapCLR("jni4net");
            string str2 = Bridge.UnwrapCLR <string>(str1);

            Assert.AreEqual("jni4net", str2);
        }
예제 #5
0
파일: BasicTests.cs 프로젝트: gywerd/WinJNI
        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;
 }
예제 #7
0
        public static Object StrongJ2CpObject(JNIEnv env, JniLocalHandle obj)
        {
            var res = new Object(env);

            ((IJvmProxy)res).Init(env, obj);
            return(res);
        }
예제 #8
0
        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)));
		}
예제 #10
0
 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));
 }
예제 #11
0
        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);
        }
예제 #12
0
 public int compareTo(Object objectPar0)
 {
     var other = Bridge.UnwrapCLR<CWithJavaInterfaceUnreg>(objectPar0);
     if (other == null)
     {
         return -1;
     }
     return other.Value.CompareTo(Value);
 }
예제 #13
0
파일: BasicTests.cs 프로젝트: gywerd/WinJNI
        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);
        }
예제 #14
0
        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);
        }
예제 #15
0
 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;
		}
예제 #17
0
        /// <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);
        }
예제 #18
0
        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);
        }
예제 #19
0
        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);
        }
예제 #20
0
        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[]) {
예제 #23
0
파일: BTests.cs 프로젝트: gywerd/WinJNI
        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[])));
		}
예제 #25
0
        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);
        }
예제 #26
0
 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);
     }
 }
예제 #27
0
        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;
		}
예제 #29
0
 public void SetObjectArrayElement(Object array, int index, IJvmProxy val)
 {
     SetObjectArrayElement(array, index, val == null ? JniGlobalHandle.Zero : val.JvmHandle);
 }
예제 #30
0
 public void SetObjectArrayElement(Object array, int index, JniHandle val)
 {
     SetObjectArrayElement(array.jvmHandle, index, val);
 }
예제 #31
0
		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));
     }
 }
예제 #34
0
 internal static Object CreateStatement(this Object target)
 {
     return(target.Invoke <Object>(Constants.Methods.CreateStatement, Constants.MethodSignatures.CreateStatement_Statement, new object[0]));
 }
예제 #35
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) {
예제 #37
0
 internal static void Commit(this Object target)
 {
     target.Invoke(Constants.Methods.Commit, Constants.MethodSignatures.Void);
 }
예제 #38
0
 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));
 }
예제 #42
0
 public void SetObjectArrayElement(Object array, int index, JniHandle val)
 {
     SetObjectArrayElement(array.jvmHandle, index, val);
 }
예제 #43
0
        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);
            }
        }
예제 #44
0
 public void SetObjectArrayElement(Object array, int index, IJvmProxy val)
 {
     SetObjectArrayElement(array, index, val == null ? JniGlobalHandle.Zero : val.JvmHandle);
 }
예제 #45
0
 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));
     }
 }
예제 #47
0
 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));
     }
 }
예제 #49
0
 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());
     }
 }
예제 #51
0
 internal int GetArrayLength(Object array)
 {
     return(GetArrayLength(array.jvmHandle));
 }
예제 #52
0
 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) {
예제 #55
0
 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) {}