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.
@ -20,7 +20,6 @@ grant // codebase "file:${user.dir}/icu4jtests.jar"
// needed for TestUtils
permission java.util.PropertyPermission "ICUDataPath", "read";
permission java.util.PropertyPermission "user.dir", "read";
permission java.util.PropertyPermission "U_RBBIDEBUG", "read";
permission java.util.PropertyPermission "GENERATE_TEST_DATA", "read";
// time zone tests

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;
/**
@ -279,6 +280,10 @@ public class RuleBasedBreakIterator extends BreakIterator {
*/
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.
@ -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.