/* * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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.
*/
publicstaticvoid main(String args[]) throws Exception { new AllLineLocations(args).startTests();
}
AllLineLocations(String args[]) { super(args);
}
protectedvoid runTests() throws Exception {
/* * Get to a point where the classes are loaded.
*/
BreakpointEvent bp = startTo("RefTypes", "loadClasses", "()V");
stepOut(bp.thread());
/* * These classes should have no line numbers, except for * one in the implicit constructor.
*/
ReferenceType rt = findReferenceType("AllAbstract"); if (rt == null) { thrownew Exception("AllAbstract: not loaded");
}
List list = rt.allLineLocations(); if (list.size() != 1) { thrownew Exception("AllAbstract: incorrect number of line locations");
} if (rt.locationsOfLine(5000).size() != 0) { thrownew Exception("AllAbstract: incorrect locationsOfLine");
}
Method method = findMethod(rt, "", "()V"); if (method == null) { thrownew Exception("AllAbstract. not found");
}
List list2 = method.allLineLocations(); if (!list2.equals(list)) { thrownew Exception("AllAbstract: line locations in wrong method");
} if (method.locationsOfLine(5000).size() != 0) { thrownew Exception("AllAbstract: incorrect locationsOfLine");
}
System.out.println("AllAbstract: passed");
rt = findReferenceType("AllNative"); if (rt == null) { thrownew Exception("AllNative: not loaded");
}
list = rt.allLineLocations(); if (list.size() != 1) { thrownew Exception("AllNative: incorrect number of line locations");
} if (rt.locationsOfLine(5000).size() != 0) { thrownew Exception("AllNative: incorrect locationsOfLine");
}
method = findMethod(rt, "", "()V"); if (method == null) { thrownew Exception("AllNative. not found");
}
list2 = method.allLineLocations(); if (!list2.equals(list)) { thrownew Exception("AllNative: line locations in wrong method");
} if (method.locationsOfLine(5000).size() != 0) { thrownew Exception("AllNative: incorrect locationsOfLine");
}
System.out.println("AllNative: passed");
rt = findReferenceType("Interface"); if (rt == null) { thrownew Exception("Interface: not loaded");
}
list = rt.allLineLocations(); if (list.size() != 0) { thrownew Exception("Interface: locations reported for abstract methods");
}
System.out.println("Interface: passed");
/* * These classes have line numbers in one method and * in the implicit constructor.
*/
rt = findReferenceType("Abstract"); if (rt == null) { thrownew Exception("Abstract: not loaded");
}
list = rt.allLineLocations(); if (list.size() != 5) { thrownew Exception("Abstract: incorrect number of line locations");
}
method = findMethod(rt, "b", "()V"); if (method == null) { thrownew Exception("Abstract.b not found");
}
list2 = method.allLineLocations();
list.removeAll(list2);
// Remaining location should be in constructor if ((list.size() != 1) ||
!(((Location)list.get(0)).method().name().equals(""))) { thrownew Exception("Abstract: line locations in wrong method");
} if (method.locationsOfLine(20).size() != 1) { thrownew Exception("Abstract method: incorrect locationsOfLine");
} if (method.locationsOfLine(5000).size() != 0) { thrownew Exception("Abstract method: incorrect locationsOfLine");
}
method = findMethod(rt, "a", "()V"); if (method.locationsOfLine(5000).size() != 0) { thrownew Exception("Abstract method: incorrect locationsOfLine");
}
System.out.println("Abstract: passed");
rt = findReferenceType("Native"); if (rt == null) { thrownew Exception("Native: not loaded");
}
list = rt.allLineLocations(); if (list.size() != 5) { thrownew Exception("Native: incorrect number of line locations");
} if (rt.locationsOfLine(5000).size() != 0) { thrownew Exception("Native: incorrect locationsOfLine");
}
method = findMethod(rt, "b", "()V"); if (method == null) { thrownew Exception("Native.b not found");
}
list2 = method.allLineLocations();
list.removeAll(list2);
// Remaining location should be in constructor if ((list.size() != 1) ||
!(((Location)list.get(0)).method().name().equals(""))) { thrownew Exception("Native: line locations in wrong method");
} if (method.locationsOfLine(30).size() != 1) { thrownew Exception("Native method: incorrect locationsOfLine");
} if (method.locationsOfLine(5000).size() != 0) { thrownew Exception("Native method: incorrect locationsOfLine");
}
method = findMethod(rt, "a", "()V"); if (method.locationsOfLine(5000).size() != 0) { thrownew Exception("Native method: incorrect locationsOfLine");
}
System.out.println("Native: passed");
rt = findReferenceType("AbstractAndNative"); if (rt == null) { thrownew Exception("AbstractAndNative: not loaded");
}
list = rt.allLineLocations(); if (list.size() != 5) { thrownew Exception("AbstractAndNative: incorrect number of line locations");
} if (rt.locationsOfLine(5000).size() != 0) { thrownew Exception("AbstractAndNative: incorrect locationsOfLine");
}
method = findMethod(rt, "c", "()V"); if (method == null) { thrownew Exception("AbstractAndNative.c not found");
}
list2 = method.allLineLocations();
list.removeAll(list2);
// Remaining location should be in constructor if ((list.size() != 1) ||
!(((Location)list.get(0)).method().name().equals(""))) { thrownew Exception("AbstractAndNative: line locations in wrong method");
}
System.out.println("AbstractAndNative: passed");
// Allow application to complete
resumeToVMDisconnect();
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.