/*
* 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 4287595
* @bug 4462989
* @bug 4531511
* @summary Test class redefinition
*
* @author Robert Field
*
* @library ..
* @run build TestScaffold VMConnection TargetListener TargetAdapter
* @run compile -g RedefineTest.java
* @run shell RedefineSetUp.sh
*/
/********** target program **********/
class RedefineTarg {
}
}
for (int i = 0; i < 5; ++i) {
}
}
}
/********** test program **********/
boolean beforeRedefine = true;
super(args);
}
}
/********** event handlers **********/
beforeRedefine = true;
try {
beforeRedefine = false;
switch (repetitionCount) {
case 1:
case 5:
break;
case 2:
case 3:
case 4:
break;
}
}
}
}
try {
}
}
}
/********** test assists **********/
if (isObsolete(thread)) {
failure("FAIL: Method should NOT be obsolete");
} else {
println("as it should be, not obsolete");
}
}
if (isObsolete(thread)) {
println("obsolete like it should be");
} else {
failure("FAIL: Method should be obsolete");
}
}
/*
* For each value of repetitionCount, use the beforeRedefine
* boolean to distinguish the time before and after the actual
* redefinition takes place. Line numbers are inspected both
* before and after each redefine.
*/
int n = -1;
int expectedLine = -1;
switch (repetitionCount) {
case 1:
expectedLine = 4;
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
/* The class won't be redefined on this iteration (look
* for a java.lang.UnsupportedOperationException instead)
* so expected line stays the same as last successful
* redefine.
*/
expectedLine = 21;
break;
}
/*
* Then skip. Obsolete methods are not interesting to
* inspect.
*/
} else {
if ((n != expectedLine) || (n != m)) {
failure("Test Failure: line number disagreement: " +
" (expected)");
} else {
}
}
}
return meth.isObsolete();
}
switch (repetitionCount) {
case 1:
fileName = "RedefineSubTarg.class";
break;
case 2:
fileName = "Different_RedefineSubTarg.class";
break;
case 3:
fileName = "RedefineSubTarg.class";
break;
case 4:
fileName = "Different_RedefineSubTarg.class";
break;
case 5:
fileName = "SchemaChange_RedefineSubTarg.class";
break;
}
" ------ Redefine as: " + fileName);
try {
}
switch (repetitionCount) {
case 5:
if (receivedException == null) {
failure("FAIL: no exception; expected: UnsupportedOperationException");
} else if (receivedException instanceof UnsupportedOperationException) {
} else {
", expected: UnsupportedOperationException");
}
break;
default:
if (receivedException != null) {
failure("FAIL: unexpected exception: " +
}
break;
}
return;
}
/********** test core **********/
/*
* Method entry in sub targ
*/
/*
* BP at end to get value
*/
throw new Exception ("TestFailure: Expected one 'lastly' method, found: " +
lastlys);
}
// Allow application to complete and shut down
/*
* deal with results of test
* if anything has called failure("foo") testFailed will be true
*/
if (!testFailed) {
println("RedefineTest: passed");
} else {
throw new Exception("RedefineTest: failed");
}
}
}