/*
* 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 4419453
* @summary Test that Method.location() returns the right values
*
* @author Robert Field
*
* @run build TestScaffold VMConnection TargetListener TargetAdapter
* @run compile -g LocationTest.java
* @run main LocationTest
*/
/********** target program **********/
abstract class AbstractLocationTarg {
abstract void foo();
}
}
void foo() {
}
}
/********** test program **********/
super(args);
}
}
/********** test assist **********/
" ReferenceTypes named: " + refName);
return null;
}
" methods named: " + methodName);
return null;
}
}
/********** test core **********/
/*
* Get to the top of main() to get everything loaded
*/
startToMain("LocationTarg");
/*
* Test the values of location()
*/
failure("location of AbstractLocationTarg.foo() should have " +
"been null, but was: " + loc);
}
failure("location of java.util.List.clear() " +
"should have been null, but was: " + loc);
}
failure("location of Object.getClass() " +
"should have been non-null, but was: " + loc);
} else {
failure("location.declaringType() of Object.getClass() " +
"should have been java.lang.Object, but was: " +
loc.declaringType());
}
failure("location.method() of Object.getClass() " +
"should have been getClass, but was: " +
}
failure("location.codeIndex() of Object.getClass() " +
"should have been -1, but was: " +
}
failure("location.lineNumber() of Object.getClass() " +
"should have been -1, but was: " +
loc.lineNumber());
}
}
failure("location of LocationTarg.foo() " +
"should have been non-null, but was: " + loc);
} else {
failure("location.declaringType() of LocationTarg.foo() " +
"should have been LocationTarg, but was: " +
loc.declaringType());
}
failure("location.method() of LocationTarg.foo() " +
"should have been foo, but was: " +
}
failure("location.codeIndex() of LocationTarg.foo() " +
"should have been 0, but was: " +
}
failure("location.lineNumber() of LocationTarg.foo() " +
}
}
/*
* resume until the end
*/
/*
* deal with results of test
* if anything has called failure("foo") testFailed will be true
*/
if (!testFailed) {
println("LocationTest: passed");
} else {
throw new Exception("LocationTest: failed");
}
}
}