Ejemplo n.º 1
0
		//    Disambiguate from org.mozilla.javascript.Node
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="System.TypeLoadException"></exception>
		private void ReadObject(ObjectInputStream stream)
		{
			stream.DefaultReadObject();
			this.dom = DocumentBuilderFactory.NewInstance();
			this.dom.SetNamespaceAware(true);
			this.dom.SetIgnoringComments(false);
			this.xform = TransformerFactory.NewInstance();
			int poolSize = Runtime.GetRuntime().AvailableProcessors() * 2;
			this.documentBuilderPool = new LinkedBlockingDeque<DocumentBuilder>(poolSize);
		}
Ejemplo n.º 2
0
		/// <exception cref="System.IO.IOException"></exception>
		private void ReadObject(ObjectInputStream ois)
		{
			w1 = ois.ReadInt();
			w2 = ois.ReadInt();
			w3 = ois.ReadInt();
			w4 = ois.ReadInt();
			w5 = ois.ReadInt();
		}
Ejemplo n.º 3
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="System.TypeLoadException"></exception>
		private void ReadObject(ObjectInputStream @is)
		{
			@is.DefaultReadObject();
			// It reads size
			int N = size;
			if (N > FIELDS_STORE_SIZE)
			{
				data = new object[N - FIELDS_STORE_SIZE];
			}
			for (int i = 0; i != N; ++i)
			{
				object obj = @is.ReadObject();
				SetImpl(i, obj);
			}
		}
Ejemplo n.º 4
0
		/// <summary>
		/// Attempts to decode Base64 data and deserialize a Java
		/// Object within.
		/// </summary>
		/// <remarks>
		/// Attempts to decode Base64 data and deserialize a Java
		/// Object within. Returns <tt>null</tt> if there was an error.
		/// If <tt>loader</tt> is not null, it will be the class loader
		/// used when deserializing.
		/// </remarks>
		/// <param name="encodedObject">The Base64 data to decode</param>
		/// <param name="options">Various parameters related to decoding</param>
		/// <param name="loader">Optional class loader to use in deserializing classes.</param>
		/// <returns>The decoded and deserialized object</returns>
		/// <exception cref="System.ArgumentNullException">if encodedObject is null</exception>
		/// <exception cref="System.IO.IOException">if there is a general error</exception>
		/// <exception cref="System.TypeLoadException">
		/// if the decoded object is of a
		/// class that cannot be found by the JVM
		/// </exception>
		/// <since>2.3.4</since>
		public static object DecodeToObject(string encodedObject, int options, ClassLoader
			 loader)
		{
			// Decode and gunzip if necessary
			byte[] objBytes = Decode(encodedObject, options);
			ByteArrayInputStream bais = null;
			ObjectInputStream ois = null;
			object obj = null;
			try
			{
				bais = new ByteArrayInputStream(objBytes);
				// If no custom class loader is provided, use Java's builtin OIS.
				if (loader == null)
				{
					ois = new ObjectInputStream(bais);
				}
				else
				{
					// end if: no loader provided
					// Else make a customized object input stream that uses
					// the provided class loader.
					ois = new _ObjectInputStream_1358(loader, bais);
				}
				// Class loader knows of this class.
				// end else: not null
				// end resolveClass
				// end ois
				// end else: no custom class loader
				obj = ois.ReadObject();
			}
			catch (IOException e)
			{
				// end try
				throw;
			}
			catch (TypeLoadException e)
			{
				// Catch and throw in order to execute finally{}
				// end catch
				throw;
			}
			finally
			{
				// Catch and throw in order to execute finally{}
				// end catch
				try
				{
					bais.Close();
				}
				catch (Exception)
				{
				}
				try
				{
					ois.Close();
				}
				catch (Exception)
				{
				}
			}
			// end finally
			return obj;
		}
Ejemplo n.º 5
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="System.TypeLoadException"></exception>
		private void ReadObject(ObjectInputStream stream)
		{
			stream.DefaultReadObject();
			int maxPrototypeId = stream.ReadInt();
			if (maxPrototypeId != 0)
			{
				ActivatePrototypeMap(maxPrototypeId);
			}
		}
Ejemplo n.º 6
0
		public virtual void TestContinuationsPrototypesAndSerialization()
		{
			byte[] serializedData = null;
			{
				Scriptable globalScope;
				Context cx = Context.Enter();
				try
				{
					globalScope = cx.InitStandardObjects();
					cx.SetOptimizationLevel(-1);
					// must use interpreter mode
					globalScope.Put("myObject", globalScope, Context.JavaToJS(new ContinuationsApiTest.MyClass(), globalScope));
				}
				finally
				{
					Context.Exit();
				}
				cx = Context.Enter();
				try
				{
					cx.SetOptimizationLevel(-1);
					// must use interpreter mode
					cx.EvaluateString(globalScope, "function f(a) { Number.prototype.blargh = function() {return 'foo';}; var k = myObject.f(a); var t = []; return new Number(8).blargh(); }", "function test source", 1, null);
					Function f = (Function)globalScope.Get("f", globalScope);
					object[] args = new object[] { 7 };
					cx.CallFunctionWithContinuations(f, globalScope, args);
					NUnit.Framework.Assert.Fail("Should throw ContinuationPending");
				}
				catch (ContinuationPending pending)
				{
					// serialize
					MemoryStream baos = new MemoryStream();
					ObjectOutputStream sos = new ObjectOutputStream(baos);
					sos.WriteObject(globalScope);
					sos.WriteObject(pending.GetContinuation());
					sos.Close();
					baos.Close();
					serializedData = baos.ToArray();
				}
				finally
				{
					Context.Exit();
				}
			}
			{
				try
				{
					Context cx = Context.Enter();
					Scriptable globalScope;
					// deserialize
					MemoryStream bais = new MemoryStream(serializedData);
					ObjectInputStream sis = new ObjectInputStream(bais);
					globalScope = (Scriptable)sis.ReadObject();
					object continuation = sis.ReadObject();
					sis.Close();
					bais.Close();
					object result = cx.ResumeContinuation(continuation, globalScope, 8);
					NUnit.Framework.Assert.AreEqual("foo", result);
				}
				finally
				{
					Context.Exit();
				}
			}
		}
Ejemplo n.º 7
0
		public virtual void TestConsStringSerialization()
		{
			ConsString r1 = new ConsString("foo", "bar");
			MemoryStream baos = new MemoryStream();
			ObjectOutputStream oos = new ObjectOutputStream(baos);
			oos.WriteObject(r1);
			oos.Flush();
			MemoryStream bais = new MemoryStream(baos.ToArray());
			ObjectInputStream ois = new ObjectInputStream(bais);
			CharSequence r2 = (CharSequence)ois.ReadObject();
			NUnit.Framework.Assert.AreEqual("still the same at the other end", r1.ToString(), r2.ToString());
		}
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="System.TypeLoadException"></exception>
 private void ReadObject(ObjectInputStream @in)
 {
     string name = (string)@in.ReadObject();
     string value = (string)@in.ReadObject();
     clientCookie = new BasicClientCookie(name, value);
     clientCookie.SetComment((string)@in.ReadObject());
     clientCookie.SetDomain((string)@in.ReadObject());
     clientCookie.SetExpiryDate((DateTime)@in.ReadObject());
     clientCookie.SetPath((string)@in.ReadObject());
     clientCookie.SetVersion(@in.ReadInt());
     clientCookie.SetSecure(@in.ReadBoolean());
 }
Ejemplo n.º 9
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="System.TypeLoadException"></exception>
		private void ReadObject(ObjectInputStream @in)
		{
			@in.DefaultReadObject();
			if (parmsLength > 0)
			{
				Type[] types = member.argTypes;
				typeTags = new byte[parmsLength];
				for (int i = 0; i != parmsLength; ++i)
				{
					typeTags[i] = unchecked((byte)GetTypeTag(types[i]));
				}
			}
			if (member.IsMethod())
			{
				MethodInfo method = member.Method();
				Type returnType = method.ReturnType;
				if (returnType == typeof(void))
				{
					hasVoidReturn = true;
				}
				else
				{
					returnTypeTag = GetTypeTag(returnType);
				}
			}
		}
Ejemplo n.º 10
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="System.TypeLoadException"></exception>
		private void ReadObject(ObjectInputStream @in)
		{
			@in.DefaultReadObject();
			int writtenKeyCount = keyCount;
			if (writtenKeyCount != 0)
			{
				keyCount = 0;
				int N = 1 << power;
				keys = new object[N];
				values = new int[2 * N];
				for (int i = 0; i != writtenKeyCount; ++i)
				{
					object key = @in.ReadObject();
					int hash = key.GetHashCode();
					int index = InsertNewKey(key, hash);
					values[index] = @in.ReadInt();
				}
			}
		}
Ejemplo n.º 11
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="System.TypeLoadException"></exception>
		private void ReadObject(ObjectInputStream @in)
		{
			@in.DefaultReadObject();
			int writtenKeyCount = keyCount;
			if (writtenKeyCount != 0)
			{
				keyCount = 0;
				bool hasIntValues = @in.ReadBoolean();
				bool hasObjectValues = @in.ReadBoolean();
				int N = 1 << power;
				if (hasIntValues)
				{
					keys = new int[2 * N];
					ivaluesShift = N;
				}
				else
				{
					keys = new int[N];
				}
				for (int i = 0; i != N; ++i)
				{
					keys[i] = EMPTY;
				}
				if (hasObjectValues)
				{
					values = new object[N];
				}
				for (int i_1 = 0; i_1 != writtenKeyCount; ++i_1)
				{
					int key = @in.ReadInt();
					int index = InsertNewKey(key);
					if (hasIntValues)
					{
						int ivalue = @in.ReadInt();
						keys[ivaluesShift + index] = ivalue;
					}
					if (hasObjectValues)
					{
						values[index] = @in.ReadObject();
					}
				}
			}
		}
Ejemplo n.º 12
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="System.TypeLoadException"></exception>
		private void ReadObject(ObjectInputStream @in)
		{
			@in.DefaultReadObject();
			this.classLoader = Context.GetCurrentContext().GetApplicationClassLoader();
		}