JMXWrapper icon indicating copy to clipboard operation
JMXWrapper copied to clipboard

ReadMe Getter/Setter example does not work correctly.

Open BlazingTwist opened this issue 1 year ago • 0 comments

The readme example:

 @JMXBean(description = "My first JMX bean test")
 public class MyBean {
 	int level = 0;
 
 	@JMXBeanAttribute(name = "Floor Level", description = "The current floor level")
 	public int getLevel() {
 		return level;
 	}
 
 	@JMXBeanAttribute
 	public void setLevel(int newLevel) {
 		level = newLevel;
 	}
 }

Creates two distinct attributes instead of correctly matching getter and setter: image

To blame are these lines: https://github.com/uklimaschewski/JMXWrapper/blob/80fad1cb25a7af68ba412c298ca11e7edc979eca/src/com/udojava/jmx/wrapper/JMXBeanWrapper.java#L631 https://github.com/uklimaschewski/JMXWrapper/blob/80fad1cb25a7af68ba412c298ca11e7edc979eca/src/com/udojava/jmx/wrapper/JMXBeanWrapper.java#L647

Intuitively, the method name should always be used to match getters and setters. (I may be biased by my reliance on IntelliJs boilerplate generation here)

BlazingTwist avatar Aug 09 '24 13:08 BlazingTwist