javaAssertions.cpp revision 2273
1879N/A * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A // Copy the name. The storage needs to exist for the the lifetime of the vm; 0N/A // it is never freed, so will be leaked (along with other option strings - 0N/A // Figure out which list the new item should go on. Names that end in "..." 0N/A // go on the package tree list. 0N/A // Delete the "...". 0N/A // Convert class/package names to internal format. Will have to convert back 0N/A // when copying to java in createJavaAssertionStatusDirectives, but that 0N/A // should happen only once. Alternative would require that 0N/A // JVM_DesiredAssertionStatus pass the external_name() to 0N/A // JavaAssertion::enabled(), but that is done once per loaded class. 0N/A for (
int i = 0; i <
len; ++i) {
0N/A // Prepend a new item to the list. Items added later take precedence, so 0N/A // prepending allows us to stop searching the list after the first match. 0N/A // Fill in the parallel names and enabled (boolean) arrays. Start at the end 0N/A // of the array and work backwards, so the order of items in the arrays 0N/A // matches the order on the command line (the list is in reverse order, since 0N/A // it was created by prepending successive items from the command line). 0N/A // Search the package list for any items that apply to classname. Each 0N/A // sub-package in classname is checked, from most-specific to least, until one 0N/A // Find the length of the "most-specific" package in classname. If classname 404N/A // does not include a package, length will be 0 which will match items for the 404N/A // default package (from options "-ea:..." or "-da:..."). 0N/A // Find the length of the next package, taking care to avoid decrementing 0N/A // past 0 (len is unsigned). 0N/A // This will be slow if the number of assertion options on the command line is 0N/A // large--it traverses two lists, one of them multiple times. Could use a 0N/A // single n-ary tree instead of lists if someone ever notices. 0N/A // First check options that apply to classes. If we find a match we're done. 0N/A // Now check packages, from most specific to least. 0N/A // No match. Return the default status.