Example #1
0
        //
        // GetInterfaces
        //

        public override Type[] GetInterfaces()
        {
            var output = new java.util.HashSet();

            GetInterfacesInternal(JavaClass, output);
            return((Type[])output.toArray(System.Type.EmptyTypes));

            void GetInterfacesInternal(java.lang.Class input, java.util.HashSet output)
            {
                foreach (var javaType in input.getGenericInterfaces())
                {
                    output.add(FromJavaGenericType(javaType));
                    if (javaType is java.lang.Class classType)
                    {
                        GetInterfacesInternal(classType, output);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// <para>
        /// Finds the resource URL closure for the given starting assembly list.
        /// </para>
        /// The closure is computed recursively from the referenced assemblies;
        /// satellite assemblies for the current culture are included also.
        /// </summary>
        /// <remarks>
        /// Referenced System, IKVM, Hsqldb core and NUnit assemblies are excluded.
        /// </remarks>
        /// <param name="startingList">The starting assembly list.</param>
        /// <returns>
        /// An array of <c>ikvmres:</c> protocol URLs describing the useful portion
        /// of the reference closure for the starting list.
        /// </returns>
        //[CLSCompliant(false)]
        public static URL[] FindResourceURLClosure(List <Assembly> startingList)
        {
            if (startingList == null)
            {
                throw new ArgumentNullException("startingList");
            }

            Set included    = new HashSet();
            Set encountered = new HashSet();

            foreach (Assembly entry in startingList)
            {
                AddAssembly(encountered, included, entry);
            }

            Assembly[] assemblies = new Assembly[included.size()];

            included.toArray(assemblies);

            URL[] urls = new URL[included.size()];

            for (int i = 0; i < assemblies.Length; i++)
            {
                Assembly entry     = assemblies[i];
                string   entryName = URLEncoder.encode(entry.FullName, "UTF-8");
                string   entryUrl  = string.Concat("ikvmres://", entryName, "/");

                try
                {
                    urls[i] = new URL(entryUrl);
                }
                catch (Exception ex)
                {
#if DEBUG
                    Debug.WriteLine("URL: " + entryUrl);
                    Debug.WriteLine(ex);
#endif
                }
            }

            return(urls);
        }
Example #3
0
            /// <summary>
            /// Gets an embedded session using the given properties.
            /// </summary>
            /// <remarks>
            /// It is assumed (but not checked) that the given properties
            /// object requests a session with a res: protocol database
            /// instance; work is performed toward configuring and locking
            /// the ambient class loading environment to correctly handle
            /// searching the transitive closure of <c>ikvmres:</c>
            /// protocol resources reachable by compile-time reference,
            /// starting with the assemblies referenced on the call stack,
            /// as well as the entry level, calling and executing assemblies
            /// and their related satellite assemblies.
            /// </remarks>
            /// <param name="properties">The properties.</param>
            /// <returns>an embedded session</returns>
            internal static HsqlSession NewEmbeddedResSession(
                HsqlProperties properties)
            {
                StackTrace trace = new StackTrace();

                java.util.Set set = new java.util.HashSet();

                foreach (StackFrame frame in trace.GetFrames())
                {
                    set.add(frame.GetMethod().DeclaringType.Assembly.FullName);
                }

                List <Assembly> startingList = new List <Assembly>();

                foreach (string name in set.toArray())
                {
                    try
                    {
                        startingList.Add(Assembly.Load(name));
                    }
                    catch { }
                }

                startingList.Add(Assembly.GetExecutingAssembly());
                startingList.Add(Assembly.GetCallingAssembly());

                if (Assembly.GetEntryAssembly() != null)
                {
                    startingList.Add(Assembly.GetEntryAssembly());
                }

                java.lang.ClassLoader loader
                    = IkvmResourceLoaderFactory.CreateLoader(startingList);

                lock (s_resLock)
                {
                    org.hsqldb.lib.ResourceStreamProvider.setLoader(loader);

                    return(HsqlSession.Factory.NewEmbeddedSession(properties));
                }
            }
            /// <summary>
            /// Gets an embedded session using the given properties.
            /// </summary>
            /// <remarks>
            /// It is assumed (but not checked) that the given properties
            /// object requests a session with a res: protocol database
            /// instance; work is performed toward configuring and locking
            /// the ambient class loading environment to correctly handle
            /// searching the transitive closure of <c>ikvmres:</c>
            /// protocol resources reachable by compile-time reference, 
            /// starting with the assemblies referenced on the call stack,
            /// as well as the entry level, calling and executing assemblies
            /// and their related satellite assemblies.
            /// </remarks>
            /// <param name="properties">The properties.</param>
            /// <returns>an embedded session</returns>
            internal static HsqlSession NewEmbeddedResSession(
                HsqlProperties properties)
            {
                StackTrace trace = new StackTrace();
                java.util.Set set = new java.util.HashSet();

                foreach (StackFrame frame in trace.GetFrames())
                {
                    set.add(frame.GetMethod().DeclaringType.Assembly.FullName);
                }

                List<Assembly> startingList = new List<Assembly>();

                foreach (string name in set.toArray())
                {
                    try
                    {
                        startingList.Add(Assembly.Load(name));
                    }
                    catch { }
                }

                startingList.Add(Assembly.GetExecutingAssembly());
                startingList.Add(Assembly.GetCallingAssembly());

                if (Assembly.GetEntryAssembly() != null)
                {
                    startingList.Add(Assembly.GetEntryAssembly());
                }

                java.lang.ClassLoader loader
                    = IkvmResourceLoaderFactory.CreateLoader(startingList);

                lock (s_resLock)
                {
                    org.hsqldb.lib.ResourceStreamProvider.setLoader(loader);

                    return HsqlSession.Factory.NewEmbeddedSession(properties);
                }
            }
        /// <summary>
        /// <para>
        /// Finds the resource URL closure for the given starting assembly list.
        /// </para>
        /// The closure is computed recursively from the referenced assemblies;
        /// satellite assemblies for the current culture are included also.
        /// </summary>
        /// <remarks>
        /// Referenced System, IKVM, Hsqldb core and NUnit assemblies are excluded.
        /// </remarks>
        /// <param name="startingList">The starting assembly list.</param>
        /// <returns>
        /// An array of <c>ikvmres:</c> protocol URLs describing the useful portion
        /// of the reference closure for the starting list.
        /// </returns>
        //[CLSCompliant(false)]
        public static URL[] FindResourceURLClosure(List<Assembly> startingList)
        {
            if (startingList == null)
            {
                throw new ArgumentNullException("startingList");
            }

            Set included = new HashSet();
            Set encountered = new HashSet();

            foreach (Assembly entry in startingList)
            {
                AddAssembly(encountered, included, entry);
            }

            Assembly[] assemblies = new Assembly[included.size()];

            included.toArray(assemblies);

            URL[] urls = new URL[included.size()];

            for (int i = 0; i < assemblies.Length; i++)
            {
                Assembly entry = assemblies[i];
                string entryName = URLEncoder.encode(entry.FullName, "UTF-8");
                string entryUrl = string.Concat("ikvmres://", entryName, "/");

                try
                {
                    urls[i] = new URL(entryUrl);
                }
                catch (Exception ex)
                {
            #if DEBUG
                    Debug.WriteLine("URL: " + entryUrl);
                    Debug.WriteLine(ex);
            #endif
                }
            }

            return urls;
        }