ICU-5926 RBBI debug code to use ICUDebug rather than directly calling System.getProperty to avoid SecurityException under Java security manager enabled.

X-SVN-Rev: 22658
This commit is contained in:
Yoshito Umaoka 2007-09-12 17:30:35 +00:00
parent 0bc787dfdf
commit 6afc33010b
4 changed files with 35 additions and 30 deletions

View File

@ -1,6 +1,6 @@
//#
//#*******************************************************************************
//#* Copyright (C) 1997-2006, International Business Machines Corporation and *
//#*******************************************************************************
//#* Copyright (C) 1997-2007, International Business Machines Corporation and *
//#* others. All Rights Reserved. *
//#*******************************************************************************
//#* This is the ant build file for ICU4J. See readme.html for more information.
@ -8,24 +8,23 @@
// policies needed to run tests
grant // codebase "file:${user.dir}/icu4jtests.jar"
{
// temporary for debugging
// permission java.lang.RuntimePermission "getProtectionDomain";
// temporary for debugging
// permission java.lang.RuntimePermission "getProtectionDomain";
// ibm 141 on ibm xp can't use reflection
permission java.lang.RuntimePermission "accessDeclaredMembers";
// ibm 141 on ibm xp can't use reflection
permission java.lang.RuntimePermission "accessDeclaredMembers";
// needed for Locale.setDefault, only used in tests and demos
permission java.util.PropertyPermission "user.language", "write";
// needed for Locale.setDefault, only used in tests and demos
permission java.util.PropertyPermission "user.language", "write";
// needed for TestUtils
permission java.util.PropertyPermission "ICUDataPath", "read";
permission java.util.PropertyPermission "user.dir", "read";
permission java.util.PropertyPermission "U_RBBIDEBUG", "read";
// needed for TestUtils
permission java.util.PropertyPermission "ICUDataPath", "read";
permission java.util.PropertyPermission "user.dir", "read";
permission java.util.PropertyPermission "GENERATE_TEST_DATA", "read";
// time zone tests
permission java.util.PropertyPermission "user.timezone", "read";
permission java.util.PropertyPermission "user.timezone", "read";
//for charsets
permission java.lang.RuntimePermission "charsetProvider", "read";
@ -43,6 +42,6 @@ grant // codebase "file:${user.dir}/icu4jtests.jar"
//
grant codebase "file:${user.dir}/icu4j.jar"
{
permission java.io.FilePermission "${/}${user.dir}${/}icu4jtests.jar", "read";
permission java.io.FilePermission "${/}${user.dir}${/}icu4j-charsets.jar", "read";
permission java.io.FilePermission "${/}${user.dir}${/}icu4jtests.jar", "read";
permission java.io.FilePermission "${/}${user.dir}${/}icu4j-charsets.jar", "read";
};

View File

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 2001-2006, International Business Machines Corporation and *
* Copyright (C) 2001-2007, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -86,7 +86,7 @@ public final class ICUDebug {
return false;
}
/* public static String value(String arg) {
public static String value(String arg) {
String result = "false";
if (debug) {
int index = params.indexOf(arg);
@ -104,7 +104,7 @@ public final class ICUDebug {
if (help) System.out.println("\nICUDebug.value(" + arg + ") = " + result);
}
return result;
}*/
}
/* static public void main(String[] args) {
// test

View File

@ -13,6 +13,7 @@ import java.io.OutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import com.ibm.icu.impl.Assert;
import com.ibm.icu.impl.ICUDebug;
class RBBIRuleBuilder {
// This is the main class for building (compiling) break rules into the tables
@ -132,7 +133,8 @@ class RBBIRuleBuilder {
//----------------------------------------------------------------------------------------
RBBIRuleBuilder(String rules)
{
fDebugEnv = System.getProperty("U_RBBIDEBUG");
fDebugEnv = ICUDebug.enabled("U_RBBIDEBUG") ?
ICUDebug.value("U_RBBIDEBUG") : null;
fRules = rules;
fUSetNodes = new ArrayList();
fRuleStatusVals = new ArrayList();

View File

@ -15,6 +15,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import com.ibm.icu.impl.Assert;
import com.ibm.icu.impl.ICUDebug;
/**
@ -261,7 +262,7 @@ public class RuleBasedBreakIterator extends BreakIterator {
* This flag lets us lazily compute the value if we are ever asked for it.
*/
private boolean fLastStatusIndexValid;
/**
* Counter for the number of characters encountered with the "dictionary"
* flag set. Normal RBBI iterators don't use it, although the code
@ -271,15 +272,19 @@ public class RuleBasedBreakIterator extends BreakIterator {
* @deprecated This API is ICU internal only.
*/
protected int fDictionaryCharCount;
/**
* Debugging flag. Trace operation of state machine when true.
* @internal
* @deprecated This API is ICU internal only.
*/
public static boolean fTrace;
/*
* ICU debug argument name for RBBI
*/
private static final String RBBI_DEBUG_ARG = "U_RBBIDEBUG";
/**
* Dump the contents of the state table and character classes for this break iterator.
* For debugging only.
@ -298,10 +303,8 @@ public class RuleBasedBreakIterator extends BreakIterator {
if (debugInitDone == false) {
String debugEnv = System.getProperty("U_RBBIDEBUG");
if (debugEnv!=null && debugEnv.indexOf("trace")>=0) {
fTrace = true;
}
fTrace = ICUDebug.enabled(RBBI_DEBUG_ARG)
&& ICUDebug.value(RBBI_DEBUG_ARG).indexOf("trace") >= 0;
debugInitDone = true;
}
}
@ -797,7 +800,8 @@ public int getRuleStatusVec(int[] fillInArray) {
* @internal
* @deprecated This API is ICU internal only.
*/
protected static String fDebugEnv = System.getProperty("U_RBBIDEBUG");
protected static String fDebugEnv = ICUDebug.enabled(RBBI_DEBUG_ARG) ?
ICUDebug.value(RBBI_DEBUG_ARG) : null;
// 32 bit Char value returned from when an iterator has run out of range.