You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2006/08/29 10:58:26 UTC
svn commit: r438018 - in
/incubator/harmony/enhanced/classlib/trunk/modules/logging: build.xml
src/main/java/java/util/logging/Logger.java
src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
Author: pyang
Date: Tue Aug 29 01:58:26 2006
New Revision: 438018
URL: http://svn.apache.org/viewvc?rev=438018&view=rev
Log:
Patch applied for HARMONY-1290 ( [classlib][logging] Logger.logrb throws unexpected AccessControlException when security manager is enable.)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/logging/build.xml
incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/build.xml?rev=438018&r1=438017&r2=438018&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/build.xml Tue Aug 29 01:58:26 2006
@@ -1,213 +1,215 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 2006 The Apache Software Foundation or its
- licensors, as applicable.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<project name="LOGGING Build" default="build" basedir=".">
- <description>Build for LOGGING component</description>
-
- <!-- import common properties -->
- <import file="${basedir}/../../make/properties.xml" />
-
- <!-- set global properties for this build. -->
- <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
-
- <fileset id="classes" dir="${hy.build}">
- <includesfile name="${hy.logging}/make/patternset.txt" />
- <excludesfile name="${hy.hdk}/build/patternsets/luni-kernel.txt" />
- <excludesfile name="${hy.hdk}/build/patternsets/security-kernel.txt" />
- </fileset>
-
- <!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
- use the Eclipse Java compiler. -->
- <property name="build.compiler" value="modern" />
-
- <target name="build" depends="compile.java, copy.jar.resources, build.jar, copy.resources" />
-
- <target name="test" depends="build, compile.tests, run.tests" />
-
- <target name="clean">
- <delete failonerror="false">
- <fileset refid="classes" />
- <fileset dir="${hy.logging.bin.test}" />
- </delete>
- </target>
-
- <target name="compile.java">
- <echo message="Compiling LOGGING classes" />
-
- <mkdir dir="${hy.build}" />
-
- <javac sourcepath=""
- srcdir="${hy.logging.src.main.java}"
- destdir="${hy.build}"
- source="${hy.javac.source}"
- target="${hy.javac.target}"
- debug="${hy.javac.debug}">
-
- <bootclasspath>
- <fileset dir="${hy.jdk}/jre/lib/boot">
- <include name="**/*.jar" />
- </fileset>
- </bootclasspath>
- </javac>
- </target>
-
- <target name="build.jar" depends="svn-info">
- <jar destfile="${hy.jdk}/jre/lib/boot/logging.jar"
- manifest="${hy.logging}/META-INF/MANIFEST.MF">
- <fileset refid="classes" />
- <manifest>
- <attribute name="Implementation-Version" value="${svn.info}"/>
- </manifest>
- </jar>
- </target>
-
- <target name="compile.tests" depends="copy.test.resources" >
- <echo message="Compiling LOGGING tests" />
-
- <mkdir dir="${hy.logging.bin.internal}" />
- <mkdir dir="${hy.logging.bin.test}" />
-
- <javac srcdir="${hy.logging.src.test.internal}"
- destdir="${hy.logging.bin.internal}"
- sourcepath=""
- source="${hy.javac.source}"
- target="${hy.javac.target}"
- debug="${hy.javac.debug}">
-
- <bootclasspath>
- <fileset dir="${hy.jdk}/jre/lib/boot">
- <include name="**/*.jar" />
- </fileset>
- </bootclasspath>
- <classpath location="${hy.hdk}/build/test/support.jar" />
- <classpath location="../../build/tests" />
- </javac>
- <javac srcdir="${hy.logging.src.test.java}"
- destdir="${hy.logging.bin.test}"
- sourcepath=""
- source="${hy.javac.source}"
- target="${hy.javac.target}"
- debug="${hy.javac.debug}">
-
- <bootclasspath>
- <fileset dir="${hy.jdk}/jre/lib/boot">
- <include name="**/*.jar" />
- </fileset>
- <pathelement path="${hy.logging.bin.internal}"/>
- </bootclasspath>
- <classpath location="${hy.hdk}/build/test/support.jar" />
- <classpath location="../../build/tests" />
- </javac>
- </target>
-
- <target name="run.tests">
-
- <mkdir dir="${hy.tests.reports}" />
-
- <property name="test.jre.home" value="${hy.jdk}/jre" />
-
- <junit fork="yes"
- forkmode="once"
- printsummary="withOutAndErr"
- errorproperty="test.errors"
- failureproperty="test.failures"
- showoutput="on"
- dir="${basedir}"
- jvm="${test.jre.home}/bin/java">
-
- <jvmarg value="-showversion"/>
-
- <env key="JAVA_HOME" value="${test.jre.home}"/>
-
- <bootclasspath>
- <fileset dir="${hy.jdk}/jre/lib/boot">
- <include name="**/*.jar" />
- </fileset>
- <pathelement path="${hy.logging.bin.internal}"/>
- </bootclasspath>
- <classpath>
- <pathelement path="${hy.logging.bin.test}"/>
- </classpath>
- <classpath location="${hy.hdk}/build/test/support.jar" />
- <classpath location="../../build/tests" />
-
- <formatter type="xml" />
-
- <test name="${test.case}" todir="${hy.tests.reports}"
- if="test.case" />
-
- <!-- run LogManagerTest in separated VM -->
- <batchtest todir="${hy.tests.reports}" haltonfailure="no"
- unless="test.case">
-
- <fileset dir="${hy.logging.src.test.java}">
- <include name="org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java"/>
- </fileset>
- </batchtest>
-
- <batchtest todir="${hy.tests.reports}" haltonfailure="no"
- unless="test.case">
-
- <fileset dir="${hy.logging.src.test.java}">
- <include name="org/apache/harmony/logging/tests/java/util/logging/*Test.java"/>
- <exclude name="org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java" />
- </fileset>
- </batchtest>
- </junit>
- <antcall target="touch-failures-file" />
- <antcall target="touch-errors-file" />
- </target>
-
- <target name="touch-failures-file" if="test.failures">
- <echo file="${hy.tests.reports}/test.failures"
- append="true">logging${line.separator}</echo>
- </target>
-
- <target name="touch-errors-file" if="test.errors">
- <echo file="${hy.tests.reports}/test.errors"
- append="true">logging${line.separator}</echo>
- </target>
-
- <target name="copy.jar.resources">
- <mkdir dir="${hy.build}" />
- <copy todir="${hy.build}" includeemptydirs="false">
- <fileset dir="${hy.logging.src.main.java}">
- <exclude name="**/*.java" />
- <exclude name="**/logging.properties" />
- </fileset>
- </copy>
- </target>
-
- <target name="copy.resources">
- <copy todir="${hy.jdk}/jre/lib" overwrite="yes" flatten="yes">
- <fileset dir="${hy.logging.src.main.java}">
- <include name="**/logging.properties" />
- </fileset>
- </copy>
- </target>
-
- <target name="copy.test.resources">
- <mkdir dir="${hy.logging.bin.test}" />
- <copy todir="${hy.logging.bin.test}" includeemptydirs="false">
- <fileset dir="${hy.logging.src.test.resources}">
- <exclude name="**/*.java" />
- </fileset>
- </copy>
- </target>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2006 The Apache Software Foundation or its
+ licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project name="LOGGING Build" default="build" basedir=".">
+ <description>Build for LOGGING component</description>
+
+ <!-- import common properties -->
+ <import file="${basedir}/../../make/properties.xml" />
+
+ <!-- set global properties for this build. -->
+ <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
+
+ <fileset id="classes" dir="${hy.build}">
+ <includesfile name="${hy.logging}/make/patternset.txt" />
+ <excludesfile name="${hy.hdk}/build/patternsets/luni-kernel.txt" />
+ <excludesfile name="${hy.hdk}/build/patternsets/security-kernel.txt" />
+ </fileset>
+
+ <!-- Set build.compiler to "org.eclipse.jdt.core.JDTCompilerAdapter" to
+ use the Eclipse Java compiler. -->
+ <property name="build.compiler" value="modern" />
+
+ <target name="build" depends="compile.java, copy.jar.resources, build.jar, copy.resources" />
+
+ <target name="test" depends="build, compile.tests, run.tests" />
+
+ <target name="clean">
+ <delete failonerror="false">
+ <fileset refid="classes" />
+ <fileset dir="${hy.logging.bin.test}" />
+ </delete>
+ </target>
+
+ <target name="compile.java">
+ <echo message="Compiling LOGGING classes" />
+
+ <mkdir dir="${hy.build}" />
+
+ <javac sourcepath=""
+ srcdir="${hy.logging.src.main.java}"
+ destdir="${hy.build}"
+ source="${hy.javac.source}"
+ target="${hy.javac.target}"
+ debug="${hy.javac.debug}">
+
+ <bootclasspath>
+ <fileset dir="${hy.jdk}/jre/lib/boot">
+ <include name="**/*.jar" />
+ </fileset>
+ </bootclasspath>
+ </javac>
+ </target>
+
+ <target name="build.jar" depends="svn-info">
+ <jar destfile="${hy.jdk}/jre/lib/boot/logging.jar"
+ manifest="${hy.logging}/META-INF/MANIFEST.MF">
+ <fileset refid="classes" />
+ <manifest>
+ <attribute name="Implementation-Version" value="${svn.info}"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="compile.tests" depends="copy.test.resources" >
+ <echo message="Compiling LOGGING tests" />
+
+ <mkdir dir="${hy.logging.bin.internal}" />
+ <mkdir dir="${hy.logging.bin.test}" />
+
+ <javac srcdir="${hy.logging.src.test.internal}"
+ destdir="${hy.logging.bin.internal}"
+ sourcepath=""
+ source="${hy.javac.source}"
+ target="${hy.javac.target}"
+ debug="${hy.javac.debug}">
+
+ <bootclasspath>
+ <fileset dir="${hy.jdk}/jre/lib/boot">
+ <include name="**/*.jar" />
+ </fileset>
+ </bootclasspath>
+ <classpath location="${hy.hdk}/build/test/support.jar" />
+ <classpath location="../../build/tests" />
+ </javac>
+ <javac srcdir="${hy.logging.src.test.java}"
+ destdir="${hy.logging.bin.test}"
+ sourcepath=""
+ source="${hy.javac.source}"
+ target="${hy.javac.target}"
+ debug="${hy.javac.debug}">
+
+ <bootclasspath>
+ <fileset dir="${hy.jdk}/jre/lib/boot">
+ <include name="**/*.jar" />
+ </fileset>
+ <pathelement path="${hy.logging.bin.internal}"/>
+ </bootclasspath>
+ <classpath location="${hy.hdk}/build/test/support.jar" />
+ <classpath location="../../build/tests" />
+ </javac>
+ </target>
+
+ <target name="run.tests">
+
+ <mkdir dir="${hy.tests.reports}" />
+
+ <property name="test.jre.home" value="${hy.jdk}/jre" />
+
+ <junit fork="yes"
+ forkmode="once"
+ printsummary="withOutAndErr"
+ errorproperty="test.errors"
+ failureproperty="test.failures"
+ showoutput="on"
+ dir="${basedir}"
+ jvm="${test.jre.home}/bin/java">
+
+ <jvmarg value="-showversion"/>
+ <!-- Required by various tests that set security manager etc -->
+ <jvmarg value="-Djava.security.policy=../../support/src/test/resources/config/testing.policy" />
+
+ <env key="JAVA_HOME" value="${test.jre.home}"/>
+
+ <bootclasspath>
+ <fileset dir="${hy.jdk}/jre/lib/boot">
+ <include name="**/*.jar" />
+ </fileset>
+ <pathelement path="${hy.logging.bin.internal}"/>
+ </bootclasspath>
+ <classpath>
+ <pathelement path="${hy.logging.bin.test}"/>
+ </classpath>
+ <classpath location="${hy.hdk}/build/test/support.jar" />
+ <classpath location="../../build/tests" />
+
+ <formatter type="xml" />
+
+ <test name="${test.case}" todir="${hy.tests.reports}"
+ if="test.case" />
+
+ <!-- run LogManagerTest in separated VM -->
+ <batchtest todir="${hy.tests.reports}" haltonfailure="no"
+ unless="test.case">
+
+ <fileset dir="${hy.logging.src.test.java}">
+ <include name="org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java"/>
+ </fileset>
+ </batchtest>
+
+ <batchtest todir="${hy.tests.reports}" haltonfailure="no"
+ unless="test.case">
+
+ <fileset dir="${hy.logging.src.test.java}">
+ <include name="org/apache/harmony/logging/tests/java/util/logging/*Test.java"/>
+ <exclude name="org/apache/harmony/logging/tests/java/util/logging/LogManagerTest.java" />
+ </fileset>
+ </batchtest>
+ </junit>
+ <antcall target="touch-failures-file" />
+ <antcall target="touch-errors-file" />
+ </target>
+
+ <target name="touch-failures-file" if="test.failures">
+ <echo file="${hy.tests.reports}/test.failures"
+ append="true">logging${line.separator}</echo>
+ </target>
+
+ <target name="touch-errors-file" if="test.errors">
+ <echo file="${hy.tests.reports}/test.errors"
+ append="true">logging${line.separator}</echo>
+ </target>
+
+ <target name="copy.jar.resources">
+ <mkdir dir="${hy.build}" />
+ <copy todir="${hy.build}" includeemptydirs="false">
+ <fileset dir="${hy.logging.src.main.java}">
+ <exclude name="**/*.java" />
+ <exclude name="**/logging.properties" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="copy.resources">
+ <copy todir="${hy.jdk}/jre/lib" overwrite="yes" flatten="yes">
+ <fileset dir="${hy.logging.src.main.java}">
+ <include name="**/logging.properties" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="copy.test.resources">
+ <mkdir dir="${hy.logging.bin.test}" />
+ <copy todir="${hy.logging.bin.test}" includeemptydirs="false">
+ <fileset dir="${hy.logging.src.test.resources}">
+ <exclude name="**/*.java" />
+ </fileset>
+ </copy>
+ </target>
+
+</project>
Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java?rev=438018&r1=438017&r2=438018&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java Tue Aug 29 01:58:26 2006
@@ -259,8 +259,13 @@
}
}
// try all class loaders up the class stack
- final Class[] classes = (new PrivateSecurityManager())
- .privateGetClassContext();
+ final Class[] classes = AccessController
+ .doPrivileged(new PrivilegedAction<Class[]>() {
+ public Class[] run() {
+ return (new PrivateSecurityManager())
+ .privateGetClassContext();
+ }
+ });
// the first class, which is PrivateSecurityManager, is skipped
for (int i = 1; i < classes.length; i++) {
final int index = i;
Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java?rev=438018&r1=438017&r2=438018&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java Tue Aug 29 01:58:26 2006
@@ -26,12 +26,13 @@
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
-import java.util.logging.LoggingPermission;
-
import java.util.logging.LoggerExtension;
+import java.util.logging.LoggingPermission;
import junit.framework.TestCase;
+
import org.apache.harmony.logging.tests.java.util.logging.util.EnvironmentHelper;
+
import tests.util.CallVerificationStack;
/**
@@ -2716,6 +2717,22 @@
assertEquals(null, r.getParameters()[0]);
assertSame(r.getThrown(), null);
}
+
+ /**
+ * @tests java.util.logging.Logger#logrb(Level, String, String, String,
+ * String, Object)
+ */
+ public void test_logrbLLevel_LString_LString_LObject_Security()
+ throws Exception {
+ // regression test for Harmony-1290
+ SecurityManager originalSecurityManager = System.getSecurityManager();
+ try {
+ System.setSecurityManager(new SecurityManager());
+ Logger.global.logrb(Level.OFF, null, null, "abc", "def");
+ } finally {
+ System.setSecurityManager(originalSecurityManager);
+ }
+ }
/*
* Test logrb(Level, String, String, String, String, Object) with null