Comments (5)
ouch...so we are storing our proxies as constants, but $ is invalid as a constant name. Perhaps we can mangle the name somehow (perhaps risk very unlikely collision of using _ in place of $ ... or dollar)?
from jmx.
Yep, that is my understanding too. Some mangling seems to be in order. You already have a method in the MBeans module that does some mangling already if the class name starts with a lowercase letter. Both dollar and _ sounds good to me and would fix the problem. Maybe dollar would make it pretty obvious what has happended?
I'll see if I can submit a patch for this tomorrow
from jmx.
Great...I guess go for 'dollar' in the patch (we can easily change this if a better idea comes along).
from jmx.
In jmx.rb there is a one line change commented below
module MBeans
##
# Create modules in this namespace for each package in the Java fully
# qualified name and return the deepest module along with the Java class
# name back to the caller.
def self.parent_for(java_class_fqn)
java_class_fqn.split(".").inject(MBeans) do |parent, segment|
# const_defined? will crash later if we don't remove $
segment.gsub!('$', 'Dollar') if segment =~ /\$/
# Note: We are boned if java class name is lower cased
return [parent, segment] if segment =~ /^[A-Z]/
segment.capitalize!
unless parent.const_defined? segment
parent.const_set segment, Module.new
else
parent.const_get segment
end
end
end
end
I created to 2 test cases to guide the patch, put them somewhere if they seem useful
def test_that_mbeans_parent_for_handles_classes_with_dollar_sign
bean_module, class_name = JMX::MBeans.parent_for("evil.dollar.Pre$Middle$Post")
assert_equal(JMX::MBeans::Evil::Dollar, bean_module)
assert_equal("PreDollarMiddleDollarPost", class_name)
end
def test_mbeans_parent_for
bean_module, class_name = JMX::MBeans.parent_for("com.example.JavaClass")
assert_equal(JMX::MBeans::Com::Example, bean_module)
assert_equal("JavaClass", class_name)
end
from jmx.
Applied this one-liner and also added these tests to jmx_mangling_test.rb. I put out a 0.8 with this change as well. Thanks for the patch and tests!
from jmx.
Related Issues (9)
- MBean attributes shouldn't be tied to MBean instance variables. HOT 4
- MBeans created by another MBean don't have attributes/operations show up HOT 2
- Extended MBeans don't have parents operations/attributes. HOT 2
- JMX::MBeanProxy#method_missing is broken HOT 3
- The url in the gemspec points to the old repo location (enebo/jmx) HOT 1
- setAttributes is internally using invoke on MBean HOT 5
- JMX::MBeans.parent_for unreliable in Jruby 9000 HOT 5
- Gem doesn't allow specifying a service url
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jmx.