зеркало из https://github.com/mozilla/gecko-dev.git
53 строки
1.8 KiB
HTML
53 строки
1.8 KiB
HTML
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<meta name="Author" content="Norris Boyd">
|
|
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
|
|
<meta name="KeyWords" content="Rhino, JavaScript, Java">
|
|
<title>Rhino FAQ</title>
|
|
</head>
|
|
<body bgcolor="#FFFFFF">
|
|
<script src="owner.js"></script>
|
|
|
|
<center>
|
|
<h1>
|
|
Frequently Asked Questions about Rhino</h1></center>
|
|
<script>document.write(owner());</script>
|
|
|
|
<br><script>
|
|
var d = new Date(document.lastModified);
|
|
document.write((d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear());
|
|
document.write('<br>');
|
|
</script>
|
|
|
|
<center>
|
|
<hr WIDTH="100%"></center>
|
|
|
|
<p><b><font size=+2>Q</font>.</b> <i>How do I create a Java array from
|
|
JavaScript?</i>
|
|
<p><b><font size=+2>A.</font></b> You must use Java reflection. For instance,
|
|
to create an array of java.lang.String of length five, do
|
|
<blockquote><tt>var stringArray = java.lang.reflect.Array.newInstance(java.lang.String,
|
|
5);</tt></blockquote>
|
|
Then if you wish to assign the string "hi" to the first element, simply
|
|
execute <tt>stringArray[0] = "hi"</tt>.
|
|
<p>Creating arrays of primitive types is slightly different: you must use
|
|
the TYPE field. For example, creating an array of seven ints can be done
|
|
with the code
|
|
<blockquote><tt>var intArray = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE,
|
|
7);</tt></blockquote>
|
|
|
|
<p><br><b><font size=+2>Q</font>.</b> <i>When I try to execute a script
|
|
I get the exception </i><tt>Required security context missing</tt><i>.
|
|
What's going on?</i>
|
|
<p><b><font size=+2>A.</font></b> You've likely missed placing the <tt>Security.properties</tt>
|
|
file in your class path at <tt>org.mozilla.javascript.resources</tt>.
|
|
<h3>
|
|
|
|
<hr WIDTH="100%"><br>
|
|
<a href="index.html">back to top</a></h3>
|
|
|
|
</body>
|
|
</html>
|