/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4947001 4954369 4954409 4954410
* @summary Test that "Boolean isX()" and "int isX()" define operations
* @author Eamonn McManus
* @run clean IsMethodTest
* @run build IsMethodTest
* @run main IsMethodTest
*/
import javax.management.*;
/*
This regression test covers a slew of bugs in Standard MBean
reflection. Lots of corner cases were incorrect:
In the MBeanInfo for a Standard MBean:
- Boolean isX() defined an attribute as if it were boolean isX()
- int isX() defined neither an attribute nor an operation
When calling MBeanServer.getAttribute:
- int get() and void getX() were considered attributes even though they
were operations in MBeanInfo
When calling MBeanServer.invoke:
- Boolean isX() could not be called because it was (consistently with
MBeanInfo) considered an attribute, not an operation
*/
public class IsMethodTest {
"define operations not attributes");
boolean ok = true;
else {
ok = false;
}
}
else {
ok = false;
}
}
try {
ok = false;
bogusAttrName + "\") should not work");
} catch (AttributeNotFoundException e) {
") got exception as expected");
}
}
try {
} catch (Exception e) {
ok = false;
") got exception: " + e);
}
}
if (ok)
else {
}
}
public static interface IsMethodMBean {
public int get();
public void getLost();
public int isWhatsit();
}
public int get() {
return 0;
}
public void getLost() {
}
}
public int isWhatsit() {
return 0;
}
}
}