コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private Object getValue(Object record) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
            internal virtual object GetValue(object record)
            {
                try
                {
                    return(Getter.invoke(record));
                }
                catch (Exception throwable)
                {
                    throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureCallFailed, throwable, "Unable to read value from record `%s`: %s", record, throwable.Message);
                }
            }
コード例 #2
0
ファイル: SunMiscUTF8Encoder.cs プロジェクト: Neo4Net/Neo4Net
 /*
  * If String.class is backed by a char[] together with an offset, return
  * the offset otherwise return 0.
  */
 private static int Offset(string value)
 {
     try
     {
         return(_getOffset == null ? 0 : ( int )_getOffset.invoke(value));
     }
     catch (Exception e)
     {
         throw new AssertionError("This encoder depends being able to access the offset in the char[] array in java.lang.String, " + "which failed: " + e.Message, e);
     }
 }
コード例 #3
0
ファイル: GrabAllocator.cs プロジェクト: Neo4Net/Neo4Net
 private static object GlobalCleaner()
 {
     MethodHandles.Lookup lookup = MethodHandles.lookup();
     try
     {
         Type         newCleaner     = Type.GetType("java.lang.ref.Cleaner");
         MethodHandle createInstance = lookup.findStatic(newCleaner, "create", MethodType.methodType(newCleaner));
         return(createInstance.invoke());
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #4
0
ファイル: SunMiscUTF8Encoder.cs プロジェクト: Neo4Net/Neo4Net
        public override ByteBuffer Encode(string input)
        {
            try
            {
                // If it's unlikely we will fit the encoded data, just use stdlib encoder
                if (input.Length > _fallbackAtStringLength)
                {
                    return(_fallbackEncoder.encode(input));
                }

                char[] rawChars = ( char[] )_getCharArray.invoke(input);
                int    len      = ( int )_arrayEncode.invoke(_charsetEncoder, rawChars, Offset(input), input.Length, @out);

                if (len == -1)
                {
                    return(_fallbackEncoder.encode(input));
                }

                _outBuf.position(0);
                _outBuf.limit(len);
                return(_outBuf);
            }
            catch (System.IndexOutOfRangeException)
            {
                // This happens when we can't fit the encoded string.
                // We try and avoid this altogether by falling back to the
                // vanilla encoder if the string looks like it'll not fit -
                // but this is probabilistic since we don't know until we've encoded.
                // So, if our guess is wrong, we fall back here instead.
                return(_fallbackEncoder.encode(input));
            }
            catch (Exception e)
            {
                throw new AssertionError("This encoder depends on sun.nio.cs.ArrayEncoder, which failed to load: " + e.Message, e);
            }
        }
コード例 #5
0
ファイル: CallSite.cs プロジェクト: ranganathsb/JavaSharp
        // this implements the upcall from the JVM, MethodHandleNatives.makeDynamicCallSite:
        internal static CallSite MakeSite(MethodHandle bootstrapMethod, String name, MethodType type, Object info, Class callerClass)
        // Callee information:
        // Extra arguments for BSM, if any:
        // Caller information:
        {
            MethodHandles.Lookup caller = IMPL_LOOKUP.@in(callerClass);
            CallSite             site;

            try
            {
                Object binding;
                info = MaybeReBox(info);
                if (info == null)
                {
                    binding = bootstrapMethod.invoke(caller, name, type);
                }
                else if (!info.GetType().IsArray)
                {
                    binding = bootstrapMethod.invoke(caller, name, type, info);
                }
                else
                {
                    Object[] argv = (Object[])info;
                    MaybeReBoxElements(argv);
                    switch (argv.Length)
                    {
                    case 0:
                        binding = bootstrapMethod.invoke(caller, name, type);
                        break;

                    case 1:
                        binding = bootstrapMethod.invoke(caller, name, type, argv[0]);
                        break;

                    case 2:
                        binding = bootstrapMethod.invoke(caller, name, type, argv[0], argv[1]);
                        break;

                    case 3:
                        binding = bootstrapMethod.invoke(caller, name, type, argv[0], argv[1], argv[2]);
                        break;

                    case 4:
                        binding = bootstrapMethod.invoke(caller, name, type, argv[0], argv[1], argv[2], argv[3]);
                        break;

                    case 5:
                        binding = bootstrapMethod.invoke(caller, name, type, argv[0], argv[1], argv[2], argv[3], argv[4]);
                        break;

                    case 6:
                        binding = bootstrapMethod.invoke(caller, name, type, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
                        break;

                    default:
                        const int NON_SPREAD_ARG_COUNT = 3;                         // (caller, name, type)
                        if (NON_SPREAD_ARG_COUNT + argv.Length > MethodType.MAX_MH_ARITY)
                        {
                            throw new BootstrapMethodError("too many bootstrap method arguments");
                        }
                        MethodType   bsmType        = bootstrapMethod.Type();
                        MethodType   invocationType = MethodType.GenericMethodType(NON_SPREAD_ARG_COUNT + argv.Length);
                        MethodHandle typedBSM       = bootstrapMethod.AsType(invocationType);
                        MethodHandle spreader       = invocationType.Invokers().SpreadInvoker(NON_SPREAD_ARG_COUNT);
                        binding = spreader.invokeExact(typedBSM, (Object)caller, (Object)name, (Object)type, argv);
                        break;
                    }
                }
                //System.out.println("BSM for "+name+type+" => "+binding);
                if (binding is CallSite)
                {
                    site = (CallSite)binding;
                }
                else
                {
                    throw new ClassCastException("bootstrap method failed to produce a CallSite");
                }
                if (!site.Target.Type().Equals(type))
                {
                    throw WrongTargetType(site.Target, type);
                }
            }
            catch (Throwable ex)
            {
                BootstrapMethodError bex;
                if (ex is BootstrapMethodError)
                {
                    bex = (BootstrapMethodError)ex;
                }
                else
                {
                    bex = new BootstrapMethodError("call site initialization exception", ex);
                }
                throw bex;
            }
            return(site);
        }