AccessSpecifierTest.java revision 2362
/*
* 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 4359628
* @summary Test fix for JDI: methods Accessible.is...() lie about array types
*
* @author Tim Bell
*
* @run build TestScaffold VMConnection TargetListener TargetAdapter
* @run compile -g AccessSpecifierTest.java
* @run main AccessSpecifierTest
*/
/********** target program **********/
/** Sample package-private interface. */
interface AccessSpecifierPackagePrivateInterface {}
/** Sample package-private class. */
class AccessSpecifierPackagePrivateClass {}
/** Sample package-private class. */
class AccessSpecifierPackagePrivateClassTwo implements
class AccessSpecifierTarg {
private boolean z0;
public byte b0;
protected short s0;
int i0;
private long l0;
public char c0;
protected float f0;
double d0;
private static class U {}
protected static class V {}
public static class W {}
static class P {} // package private
private static interface StaticInterface {}
private static class ClassUsingStaticInterface
implements StaticInterface {}
public AccessSpecifierTarg() {
super();
}
public void ready(){
}
}
}
/********** test program **********/
public class AccessSpecifierTest extends TestScaffold {
/** Known Accessible Information about the Debugee. */
private static final int NAME = 0;
private static final int ACCESS = 1;
private final static String primitives[][] = {
{"z", "private", "public", "public"},
{"b", "public", "public", "public"},
{"s", "protected", "public", "public"},
{"i", "package private", "public", "public"},
{"l", "private", "public", "public"},
{"c", "public", "public", "public"},
{"f", "protected", "public", "public"},
{"d", "package private", "public", "public"},
};
private final static String references[][] = {
{"java.lang.Boolean" , "public"},
{"java.lang.Character", "public"},
{"java.lang.Class" , "public"},
{"java.lang.Double" , "public"},
{"java.lang.Float" , "public"},
{"java.lang.Integer" , "public"},
{"java.lang.Long" , "public"},
{"java.lang.String" , "public"},
{"java.lang.Object" , "public"},
{"AccessSpecifierTarg", "package private"},
{"AccessSpecifierPackagePrivateClass", "package private"},
{"AccessSpecifierPackagePrivateInterface", "package private"},
{"AccessSpecifierTarg$StaticInterface", "private"},
{"AccessSpecifierTarg$U", "private"},
{"AccessSpecifierTarg$V", "protected"},
{"AccessSpecifierTarg$W", "public"},
{"AccessSpecifierTarg$P", "package private"}
};
super(args);
}
}
/********** test core **********/
boolean isPublic, boolean isProtected,
boolean isPrivate, boolean isPackagePrivate) {
" isPublic() was: " + a.isPublic());
}
" isPrivate() was: " + a.isPrivate());
}
if (a.isProtected() != isProtected) {
" isProtected() is: " + a.isProtected());
}
if (a.isPackagePrivate() != isPackagePrivate) {
" isPackagePrivate() is: " + a.isPackagePrivate());
}
}
/*
* Get to the top of ready()
*/
}
for (int j = 0; j < 3; j++) {
}
if (t instanceof ReferenceType) {
true, false, false, false);
false, true, false, false);
false, false, true, false);
false, false, false, true);
}
} else {
" (primitive scalar type)");
}
}
}
for (int j = 0; j < 3; j++) {
" (not found)");
} else {
}
}
}
}
/*
* resume the target listening for events
*/
/*
* deal with results of test
* if anything has called failure("foo") testFailed will be true
*/
if (!testFailed) {
println("AccessSpecifierTest: passed");
} else {
throw new Exception("AccessSpecifierTest: failed");
}
}
}