Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            // jsc needs to see args to make Main into main for javac..


            // see also>
            // X:\jsc.svn\examples\javascript\android\AndroidBroadcastLogger\AndroidBroadcastLogger\ApplicationWebService.cs

            System.Console.WriteLine(
               typeof(object).AssemblyQualifiedName
            );


            //java.lang.Object, rt
            //{{ x = {{ ProcessorCount = 4 }} }}


            // modifying vmware ProcessorCount  requires a reboot of the client vm.
            var x = new { Environment.ProcessorCount };

            // \\192.168.1.189\staging

            Console.WriteLine(new { x });

            //CLRProgram.CLRMain();

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            // jsc needs to see args to make Main into main for javac..


            // see also>
            // X:\jsc.svn\examples\javascript\android\AndroidBroadcastLogger\AndroidBroadcastLogger\ApplicationWebService.cs

            System.Console.WriteLine(
               typeof(object).AssemblyQualifiedName
            );

            try
            {
                //- javac
                //"C:\Program Files (x86)\Java\jdk1.7.0_45\bin\javac.exe" -classpath "Y:\staging\web\java";release -d release java\JVMCLRFirstOrDefault\Program.java
                //java\JVMCLRFirstOrDefault\Program.java:31: error: method Of in class __SZArrayEnumerator_1<T#2> cannot be applied to given types;
                //            num1 = __Enumerable.<Long>FirstOrDefault(__SZArrayEnumerator_1.<Long>Of(numArray0));
                //                                                                          ^
                //  required: T#1[]
                //  found: long[]
                //  reason: actual argument long[] cannot be converted to Long[] by method invocation conversion
                //  where T#1,T#2 are type-variables:
                //    T#1 extends Object declared in method <T#1>Of(T#1[])
                //    T#2 extends Object declared in class __SZArrayEnumerator_1

                //var e = new long[0];
                {
                    var e = new item[0];


                    var z = e.Select(x => x.value).FirstOrDefault();

                    Console.WriteLine(new { z });
                }

                {
                    var e = new[] { new item { value = 
                        
                        //Error	1	Cannot implicitly convert type 'int' to 'JVMCLRFirstOrDefault.xlong'. An explicit conversion exists (are you missing a cast?)	X:\jsc.svn\examples\java\Test\JVMCLRFirstOrDefault\JVMCLRFirstOrDefault\Program.cs	68	56	JVMCLRFirstOrDefault
                        (JVMCLRFirstOrDefault.xlong)
                        666 } };


                    var z = e.Select(x => x.value).FirstOrDefault();

                    Console.WriteLine(new { z });
                }
            }
            catch
            {
                Console.WriteLine("NOK");
            }


            CLRProgram.CLRMain();
        }
Ejemplo n.º 3
0
        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201511/20151122

        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201510/20151023/ubuntuwebapplication
        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201510/20151012


        static async void IntegrityWatchdog(FileInfo f)
        {
            var user = jvm::java.lang.System.getProperty("user.name");
            var snapshot = new { f.Length };


            Console.WriteLine("hello. " + new { user, f.Name, snapshot.Length });

            do
            {
                await Task.Delay(1000);
            }
            while (f.Length == snapshot.Length);

            Console.WriteLine("module has been changed. " + new { user, f.Name, f.Length });

            Environment.Exit(555);
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            // jsc needs to see args to make Main into main for javac..


            // see also>
            // X:\jsc.svn\examples\javascript\android\AndroidBroadcastLogger\AndroidBroadcastLogger\ApplicationWebService.cs



            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201408/20140810/asenumerable
            IEnumerable<object> e = new[] { new object() };
            //IEnumerable<object> e = new[] { new object() }.AsEnumerable();

            // how do the other jsc languages behave?

            // {{ AssemblyQualifiedName = java.lang.Object, rt, e = ScriptCoreLib.Shared.BCLImplementation.System.__SZArrayEnumerator_1@16fe0f4 }}
            Console.WriteLine(new { typeof(object).AssemblyQualifiedName, e });


            CLRProgram.CLRMain();
        }
Ejemplo n.º 5
0
        public static void Main2(string[] args)
        {
            System.Console.WriteLine(
               typeof(object).AssemblyQualifiedName
            );



            var keystore0 = new FileInfo(
              new FileInfo(typeof(Program2).Assembly.Location).Directory.FullName + "/.keystore"
             );


            // do we have the keys?
            Console.WriteLine(new { keystore0 });
            // { keystore0 = { FullName = /home/xmikro/Desktop/staging/.keystore, Exists = true } }



            try
            {

                var xSSLContext = jvm::javax.net.ssl.SSLContext.getInstance("TLSv1.2");
                var xTrustEveryoneManager = new[] { new ScriptCoreLib.Java.TrustEveryoneManager() };
                var xKeyManager = new[] { new ScriptCoreLib.Java.localKeyManager(keystorepath: keystore0.FullName) };

                //Console.WriteLine("SSLContext init...");
                xSSLContext.init(
                    // SunMSCAPI ?
                    xKeyManager,
                    xTrustEveryoneManager,
                    new jvm::java.security.SecureRandom()
                );

                var xSSLSocketFactory = xSSLContext.getSocketFactory();
                var xSSLServerSocketFactory = xSSLContext.getServerSocketFactory();



                // init once
                UpgradeToSSL_server = xSSLServerSocketFactory.createServerSocket(UpgradeToSSL_serverport) as jvm::javax.net.ssl.SSLServerSocket;




                // first are we able to run async?


                var s = new SemaphoreSlim(0);

                //java.lang.Object, rt
                //enter async { ManagedThreadId = 1 }
                //awaiting for SemaphoreSlim{ ManagedThreadId = 1 }
                //after delay{ ManagedThreadId = 8 }
                //http://127.0.0.1:8080
                //{ fileName = http://127.0.0.1:8080 }
                //enter catch { mname = <0032> nop.try } ClauseCatchLocal:
                //{ Message = , StackTrace = java.lang.RuntimeException
                //        at ScriptCoreLibJava.BCLImplementation.System.Net.Sockets.__TcpListener.AcceptTcpClientAsync(__TcpListener.java:131)

                new { }.With(
                    async delegate
                    {
                        //System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                        //enter async { ManagedThreadId = 1 }
                        //awaiting for SemaphoreSlim{ ManagedThreadId = 1 }
                        //after delay{ ManagedThreadId = 4 }
                        //http://127.0.0.1:8080
                        //awaiting for SemaphoreSlim. done.{ ManagedThreadId = 1 }
                        //--
                        //accept { c = System.Net.Sockets.TcpClient, ManagedThreadId = 6 }
                        //System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                        //accept { c = System.Net.Sockets.TcpClient, ManagedThreadId = 8 }
                        //{ ManagedThreadId = 6, input = GET / HTTP/1.1


                        Console.WriteLine("enter async " + new { Thread.CurrentThread.ManagedThreadId });

                        // X:\jsc.svn\examples\javascript\chrome\apps\ChromeTCPServerAsync\ChromeTCPServerAsync\Application.cs
                        await Task.Delay(100);

                        Console.WriteLine("after delay" + new { Thread.CurrentThread.ManagedThreadId });

                        // Additional information: Only one usage of each socket address (protocol/network address/port) is normally permitted
                        // close the other server!

                        //var l = new TcpListener(IPAddress.Any, 8080);

                        var port = 8083;
                        var l = new TcpListener(IPAddress.Any, port);

                        l.Start();


                        var href =
                            "http://127.0.0.1:" + port;

                        Console.WriteLine(
                            href
                        );


                        // running on ubuntu?

                        //Process.Start(
                        //    href
                        //);


                        new { }.With(
                            async delegate
                            {
                                while (true)
                                {
                                    var c = await l.AcceptTcpClientAsync();

                                    Console.WriteLine("accept " + new { c, Thread.CurrentThread.ManagedThreadId });

                                    yield(c, xSSLServerSocketFactory);
                                }
                            }
                        );

                        // jump back to main thread..
                        s.Release();
                    }
                );

                Console.WriteLine("awaiting for SemaphoreSlim" + new { Thread.CurrentThread.ManagedThreadId });
                s.Wait();
                Console.WriteLine("awaiting for SemaphoreSlim. done." + new { Thread.CurrentThread.ManagedThreadId });

            }
            catch
            {
                throw;
            }

            //System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces().WithEach(
            // n =>
            // {
            //	 // X:\jsc.svn\core\ScriptCoreLibJava\BCLImplementation\System\Net\NetworkInformation\NetworkInterface.cs

            //	 var IPProperties = n.GetIPProperties();
            //	 var PhysicalAddress = n.GetPhysicalAddress();

            //	 var InetAddressesString = "";


            //	 foreach (var ip in IPProperties.UnicastAddresses)
            //	 {
            //		 //if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
            //		 //{
            //		 //Console.WriteLine(ip.Address.ToString());
            //		 InetAddressesString += ", " + ip.Address;
            //		 //}
            //	 }

            //	 // Address = {192.168.43.1}
            //	 //IPProperties.GatewayAddresses.WithEach(
            //	 //    g =>
            //	 //    {
            //	 //        InetAddressesString += ", " + g.Address;
            //	 //    }
            //	 //);


            //	 Console.WriteLine(new
            //	 {
            //		 n.OperationalStatus,

            //		 n.Name,
            //		 n.Description,
            //		 n.SupportsMulticast,
            //		 //n.NetworkInterfaceType,

            //		 InetAddressesString
            //	 });
            // }
            //);

            Console.WriteLine("--");


            Console.ReadLine();

            //CLRProgram.CLRMain();
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            // jsc needs to see args to make Main into main for javac..

            System.Console.WriteLine("hi");

            try
            {

                // see also>
                // X:\jsc.svn\examples\javascript\android\AndroidBroadcastLogger\AndroidBroadcastLogger\ApplicationWebService.cs

                System.Console.WriteLine(
                   typeof(object).AssemblyQualifiedName
                );

                //- javac
                //"C:\Program Files (x86)\Java\jdk1.7.0_45\bin\javac.exe" -classpath "Y:\staging\web\java";release -d release java\JVMCLRLinqAverage\Program.java
                //java\JVMCLRLinqAverage\Program.java:35: error: generic array creation
                //        type_9__27__28_0_1Array2 = new __AnonymousTypes__JVMCLRLinqAverage__i__d_jvm.__f__AnonymousType_9__27__28_0_1<Integer>[] {
                //                                   ^
                //java\JVMCLRLinqAverage\Program.java:56: error: method Average_0600046d in class __Enumerable cannot be applied to given types;
                //        double1 = __Enumerable.<__AnonymousTypes__JVMCLRLinqAverage__i__d_jvm.__f__AnonymousType_9__27__28_0_1<Integer>>Average_0600046d(__SZArrayEnumerator_1.<__AnonymousTypes__JVMCLRLinqAverage__i__d_jvm.__f__AnonymousType_9__27__28_0_1<Integer>>Of(type_9__27__28_0_1Array3), func_24);
                //                              ^
                //  required: __IEnumerable_1<TSource>,__Func_2<TSource,Double>
                //  found: __SZArrayEnumerator_1<__f__AnonymousType_9__27__28_0_1<Integer>>,__Func_2<__f__AnonymousType_9__27__28_0_1<Integer>,Integer>
                //  reason: actual argument __Func_2<__f__AnonymousType_9__27__28_0_1<Integer>,Integer> cannot be converted to __Func_2<__f__AnonymousType_9__27__28_0_1<Integer>,Double> by method invocation conversion
                //  where TSource is a type-variable:
                //    TSource extends Object declared in method <TSource>Average_0600046d(__IEnumerable_1<TSource>,__Func_2<TSource,Double>)
                //Y:\staging\web\java\ScriptCoreLib\Shared\BCLImplementation\System\Linq\__Enumerable.java:1720: error: inconvertible types
                //                num2 = ((int)(enumerator_15.System_Collections_Generic_IEnumerator_1_get_Current()));
                //                             ^
                //  required: int
                //  found:    Double
                //Y:\staging\web\java\ScriptCoreLib\Shared\BCLImplementation\System\Linq\__Enumerable.java:1769: error: inconvertible types
                //                num2 = ((int)(enumerator_15.System_Collections_Generic_IEnumerator_1_get_Current()));
                //            //                             ^

                //- javac
                //"C:\Program Files (x86)\Java\jdk1.7.0_45\bin\javac.exe" -classpath "Y:\staging\web\java";release -d release java\JVMCLRLinqAverage\Program.java
                //java\JVMCLRLinqAverage\Program.java:37: error: generic array creation
                //        type_9__27__28_0_1Array3 = new __AnonymousTypes__JVMCLRLinqAverage__i__d_jvm.__f__AnonymousType_9__27__28_0_1<Integer>[] {
                //                                   ^
                //java\JVMCLRLinqAverage\Program.java:58: error: method Average_0600046d in class __Enumerable cannot be applied to given types;
                //        double2 = __Enumerable.<__AnonymousTypes__JVMCLRLinqAverage__i__d_jvm.__f__AnonymousType_9__27__28_0_1<Integer>>Average_0600046d(__SZArrayEnumerator_1.<__AnonymousTypes__JVMCLRLinqAverage__i__d_jvm.__f__AnonymousType_9__27__28_0_1<Integer>>Of(type_9__27__28_0_1Array4), func_25);
                //                              ^
                //  required: __IEnumerable_1<TSource>,__Func_2<TSource,Double>
                //  found: __SZArrayEnumerator_1<__f__AnonymousType_9__27__28_0_1<Integer>>,__Func_2<__f__AnonymousType_9__27__28_0_1<Integer>,Integer>
                //  reason: actual argument __Func_2<__f__AnonymousType_9__27__28_0_1<Integer>,Integer> cannot be converted to __Func_2<__f__AnonymousType_9__27__28_0_1<Integer>,Double> by method invocation conversion
                //  where TSource is a type-variable:
                //    TSource extends Object declared in method <TSource>Average_0600046d(__IEnumerable_1<TSource>,__Func_2<TSource,Double>)
                //Note: Some input files use unchecked or unsafe operations.


                //var z = new { Int32 = 0 };
                var z = new __item { Int32 = 0 };
                //var x = new[] { z };
                var x = new[] { z };
                var a = x.Average(xx => xx.Int32);

                Console.WriteLine(new { a });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());

            }

            //String.Concat
            CLRProgram.CLRMain();
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            // jsc needs to see args to make Main into main for javac..


            // see also>
            // X:\jsc.svn\examples\javascript\android\AndroidBroadcastLogger\AndroidBroadcastLogger\ApplicationWebService.cs

            System.Console.WriteLine(
               typeof(object).AssemblyQualifiedName
            );


            //java.lang.Object, rt
            //{{ x = {{ ProcessorCount = 4 }} }}

            var x = new { Thread.CurrentThread.ManagedThreadId, Environment.ProcessorCount };

            Console.WriteLine(new { x });

            //{ x = { ManagedThreadId = 1, ProcessorCount = 4 } }
            //worker1 { ManagedThreadId = 3 }
            //WhenAll { ManagedThreadId = 3, ProcessorCount = 4 }
            // X:\jsc.svn\examples\javascript\appengine\XSLXAssetWithXElement\XSLXAssetWithXElement\ApplicationWebService.cs

            var t0 = Task.Run(
                //async 
                delegate
                {
                    Console.WriteLine("worker1 start " + new { Thread.CurrentThread.ManagedThreadId });

                    Thread.Sleep(1000);
                    Console.WriteLine("worker1 end " + new { Thread.CurrentThread.ManagedThreadId });
                }
            );


            //{ x = { ManagedThreadId = 1, ProcessorCount = 4 } }
            //worker1 start { ManagedThreadId = 3 }
            //worker1 end { ManagedThreadId = 3 }
            //WhenAll { ManagedThreadId = 4, ProcessorCount = 4 }
            //after Wait { ManagedThreadId = 1, ProcessorCount = 4 }


            // CLR seems to continue the worker thread to continuewith

            var ttt = Task.WhenAll(t0).ContinueWith(
                tt =>
                {
                    Console.WriteLine(
                        "WhenAll " +
                        new { Thread.CurrentThread.ManagedThreadId, Environment.ProcessorCount }
                    );


                }
            );


            ttt.Wait();

            Console.WriteLine(
                   "after Wait " +
                   new { Thread.CurrentThread.ManagedThreadId, Environment.ProcessorCount }
               );

            //{ x = { ManagedThreadId = 1, ProcessorCount = 4 } }
            //worker1 start { ManagedThreadId = 8 }
            //worker1 end { ManagedThreadId = 8 }
            //WhenAll { ManagedThreadId = 8, ProcessorCount = 4 }
            //after Wait { ManagedThreadId = 1, ProcessorCount = 4 }

            CLRProgram.CLRMain();
        }