Since I just stumbled over this I would like to know why I’m able to do
something like Java::JavaxSwingJTable.new instead of
Java::JavaxSwing.JTable.new
Shouldn’t that be an error ?
Regards
Roger
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
On Sat, Jun 5, 2010 at 11:28 AM, Roger G. [email protected] wrote:
Since I just stumbled over this I would like to know why I’m able to do something like Java::JavaxSwingJTable.new instead of Java::JavaxSwing.JTable.new
Since Java packages are lower case and classes are upper case, it is
easy to figure what you need.
For instance, this works
Java::javax.swing.JTable.new
but this doesn’t
Java::javax.Swing.JTable.new (no JRE package by that name)
but this does
Java::Javax.swing.JTable.new (top level package - in JRE it has to
be lower case)
The down side is it takes extra time - up to factor a of 20-30 longer.
The error is the time penalty.
Also, with Java:: for JRE packages, you only need
require ‘java’
you don’t need to include the classes.
–
Enjoy global warming while it lasts.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
What do you mean when you say it’s a factor of 20-30 longer for one or
the other? They should be identical
~/projects/jruby âž” time jruby -rjava -e “p Java::Javax.swing.JTable.new”
#Java::JavaxSwing::JTable:0x1f07597
real 0m2.885s
user 0m1.152s
sys 0m0.167s
~/projects/jruby âž” time jruby -rjava -e “p Java::javax.swing.JTable.new”
#Java::JavaxSwing::JTable:0x54824
real 0m2.638s
user 0m1.118s
sys 0m0.156s
Obviously the one that errors runs much faster because it doesn’t do
anything…
On Sat, Jun 5, 2010 at 2:27 PM, Agile A. [email protected]
wrote:
but this doesn’t
The error is the time penalty.
To unsubscribe from this list, please visit:
  http://xircles.codehaus.org/manage_email
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
On Sat, Jun 5, 2010 at 2:36 PM, Roger G. [email protected] wrote:
Since Java packages are lower case and classes are upper case, it is
easy to figure what you need.
Thats true. But I do not understand why something like
Java::javax.swingJTable.new even executes. It seems to be a module. But who
defined it ? Is it automaticaly created by JRuby ? What is it good for ?
Sorry, I have no idea - I just poke it and see what falls out.
–
Enjoy global warming while it lasts.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Since Java packages are lower case and classes are upper case, it is
easy to figure what you need.
Thats true. But I do not understand why something like
Java::javax.swingJTable.new even executes. It seems to be a module. But
who defined it ? Is it automaticaly created by JRuby ? What is it good
for ?
the down side is it takes extra time - up to factor a of 20-30 longer.
Couldn’t reproduce it either.
Regards
Roger
On Sat, Jun 5, 2010 at 3:17 PM, Cinaed S. [email protected]
wrote:
the down side is it takes extra time - up to factor a of 20-30 longer.
Couldn’t reproduce it either.
Hi - not sure if this email was sent from GMail - could’t find the sent
email.
If it was sent I apologize for the noise.
I’m running this in JRuby 1.4 (on CentOS 5 on a netbook.)
Case 1:
require ‘java’
t1 = Time.new
1.upto 1000 do
x=Java::JTable.new
y=Java::JLabel.new
b=Java::JButton.new
a=Java::Class.new
end
puts (Time.now - t1) * 1000
TIME=124
Case 2:
require ‘java’
t1 = Time.new
1.upto 1000 do
x = Java::javax.swing.JTable.new
y = Java::javax.swing.JLabel.new
b = Java::javax.swing.JButton.new
a = x.getClass().name
end
puts (Time.now - t1) * 1000
TIME=3163
–
Enjoy global warming while it lasts.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Regarding case 1.
You don’t create a JTable here. It’s a module. For more strangeness
try:
require “java”
x=Java::JTable.new
puts x.getRowCount()
Regarding case 2 + 3: They need about the same time to finish here (1.6
seconds)
Regards
Roger
Am 06.06.2010 um 01:11 schrieb Agile A.:
1.upto 1000 do
Bottom line, if you mix Java:: with JRE’s package name, e.g.,
http://xircles.codehaus.org/manage_email
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Dang, I forgot Case 3 - which has the same time as Case 1 but only
uses JRE’s package names.
Case 3:
require ‘java’
t1 = Time.new
1.upto 1000 do
x = javax.swing.JTable.new
y = javax.swing.JLabel.new
b = javax.swing.JButton.new
a = x.getClass().name
end
puts (Time.now - t1) * 1000
TIME=124
Bottom line, if you mix Java:: with JRE’s package name, e.g.,
Java::javax.swing.JTable, then you may take a performance hit (but for
a single invocation the time differences appears to be small.)
–
Enjoy global warming while it lasts.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email