Hi,
On Mon, May 08, 2000 at 07:20:10PM -0700, Tom Tromey wrote:
>
> Before I can check these in, I have to know that you have signed
> paperwork with the FSF. If you already have, I'm sorry for asking
> again. I don't know who has or has not.
Yes I signed an 'assigned of copyright in revisions of GNU Classpath'
document back in december when I was working on java.util.jar (which I
still haven't finished, but one of these days...). I believe that Paul
Fisher is the guardian of the copyright papers for the Classpath project.
If you are going to check this in could you also check in some other
stuff that I send to the list but that never made it into the tree?
Here is a changelog entry and attached is the diff for the other stuff
* java/lang/ThreadLocal.java: new 1.2 class
* java/lang/InheritableThreadLocal.java: new 1.2 class
* vm/reference/java/lang/Thread.java: added example to use ThreadLocals
* java/lang/Package.java: new 1.2 class (except for support in ClassLoader)
* java/security/ProtectionDomain.java: constructor should make the
PermissionCollection read only.
Thanks,
Mark
P.S. I don't have that much time but I am currently working on java.util.jar
(which is partially done), java.net.URLClassLoader (should be checked with
the libgcj one), java.util.Timer (from 1.3, almost done) and Package support
in java.lang.ClassLoader (which I think can be done in pure java). Please let
me know if you really need this and think I am taking much to long then I can
send you what I have now.
P.P.S I notice that my coding style is different from the coding styles used
in Classpath. Is there an agreed upon coding style and is there a way I can
convince emacs to use it? Or is there a code beautifier/identer for that
style?
Index: java/security/ProtectionDomain.java
===================================================================
RCS file: /cvs/classpath/java/security/ProtectionDomain.java,v
retrieving revision 1.2
diff -u -r1.2 ProtectionDomain.java
--- java/security/ProtectionDomain.java 2000/03/16 20:18:22 1.2
+++ java/security/ProtectionDomain.java 2000/05/09 07:48:45
@@ -77,15 +77,23 @@
/**
* This method initializes a new instance of <code>ProtectionDomain</code>
* representing the specified <code>CodeSource</code> and permission set.
+ * No permissions may be added to the <code>PermissionCollection</code>
+ * and this contructor will call the <code>setReadOnly</code> method on
+ * the specified permission set.
*
* @param code_source The <code>CodeSource</code> for this domain
* @param perms The permission set for this domain
+ *
+ * @see java.security.PermissionCollection#setReadOnly()
*/
public
ProtectionDomain(CodeSource code_source, PermissionCollection perms)
{
this.code_source = code_source;
this.perms = perms;
+ if (perms != null) {
+ perms.setReadOnly();
+ }
}
/*************************************************************************/
/*
* java.lang.Package: part of the Java Class Libraries project.
* Copyright (C) 1999 Free Software Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package java.lang;
import java.net.URL;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
/**
* Everything you ever wanted to know about a package. This class makes it
* possible to attach specification and implementation information to a
* package as explained in the
* <a href="http://java.sun.com/products/jdk/1.3/docs/guide/versioning/spec/VersioningSpecification.html#PackageVersionSpecification">Package Versioning Specification</a>
* section of the
* <a href="http://java.sun.com/products/jdk/1.3/docs/guide/versioning/spec/VersioningSpecification.html">Product Versioning Specification</a>.
* It also allows packages to be sealed with respect to the originating URL.
* <p>
* The most usefull method is the <code>isCompatibleWith()</code> method that
* compares a desired version of a specification with the version of the
* specification as implemented by a package. A package is considered compatible
* with another version if the version of the specification is equal or higer
* then the requested version. Version numbers are represented as strings of
* positive numbers seperated by dots (e.g. "1.2.0"). The first number is called
* the major number, the second the minor, the third the micro, etc. A version
* is considered higher then another version if it has a bigger major number
* then the another version or when the major numbers of the versions are equal
* if it has a bigger minor number then the other version, etc. (If a version
* has no minor, micro, etc numbers then they are considered the be 0.)
*
* @since JDK1.2
* @author Mark Wielaard
* @version 1.0, 19 Dec 1999
*/
public class Package {
// Variables
/** The name of the Package
*/
final private String name;
/** The name if the implementation
*/
final private String implTitle;
/** The vendor that wrote this implementation
*/
final private String implVendor;
/** The version of this implementation
*/
final private String implVersion;
/** The name of the specification
*/
final private String specTitle;
/** The name of the specification designer
*/
final private String specVendor;
/** The version of this specification
*/
final private String specVersion;
/** If sealed the origin of the package classes
*/
final private URL sealed;
// Constructors
/**
* A package local constructor for the Package class.
* XXX - There are no public constructors defined for Package so I just
* invented a package local constructor that can be used by classes in
* java.lang.
*
* @param name The name of the Package
* @param implTitle The name of the implementation
* @param implVendor The vendor that wrote this implementation
* @param implVersion The version of this implementation
* @param specTitle The name of the specification
* @param specVendor The name of the specification designer
* @param specVersion The version of this specification
* @param sealed If sealed the origin of the package classes
*/
Package(String name,
String implTitle, String implVendor, String implVersion,
String specTitle, String specVendor, String specVersion,
URL sealed) {
this.name = name;
this.implTitle = implTitle;
this.implVendor = implVendor;
this.implVersion = implVersion;
this.specTitle = specTitle;
this.specVendor = specVendor;
this.specVersion = specVersion;
this.sealed = sealed;
}
// Methods
/**
* Returns the Package name.
*/
public String getName() {
return name;
}
/**
* Returns the name of the implementation or null if unknown.
*/
public String getImplementationTitle() {
return implTitle;
}
/**
* Returns the vendor that wrote this implementation or null if unknown.
*/
public String getImplementationVendor() {
return implVendor;
}
/**
* Returns the version of this implementation or null if unknown.
*/
public String getImplementationVersion() {
return implVersion;
}
/**
* Returns the name of the specification or null if unknown.
*/
public String getSpecificationTitle() {
return specTitle;
}
/**
* Returns the name of the specification designer.
*/
public String getSpecificationVendor() {
return specVendor;
}
/**
* Returns the version of the specification or null if unknown.
*/
public String getSpecificationVersion() {
return specVersion;
}
/**
* Returns true if this Package is sealed.
*/
public boolean isSealed() {
return (sealed != null);
}
/**
* Returns true if this Package is sealed and the origin of the classes is
* the given URL.
*
* @param url
*/
public boolean isSealed(URL url) {
return url.equals(sealed);
}
/**
* Checks if the version of the specification is higher or at least as high
* as the desired version.
* XXX - It may throw unexpected (NullPointer) exceptions when the supplied
* version or the specification version are null.
* @param version the (minimal) desired version of the specification
* @exception NumberFormatException when either version or the specification
* version is not a correctly formatted version number
*/
public boolean isCompatibleWith(String version) throws
NumberFormatException {
StringTokenizer versionTokens = new StringTokenizer(version, ".");
StringTokenizer specTokens = new StringTokenizer(specVersion, ".");
try {
while (versionTokens.hasMoreElements()) {
int vers = Integer.parseInt(versionTokens.nextToken());
int spec = Integer.parseInt(specTokens.nextToken());
if (spec < vers) {
return false;
} else if (spec > vers) {
return true;
}
// They must be equal, next Token please!
}
} catch (NoSuchElementException e) {
// this must have been thrown by spec.netToken() so return false
return false;
}
// They must have been exactly the same version.
// Or the specVersion has more subversions. That is also good.
return true;
}
/**
* Returns the named package if it is known by the callers class loader.
* It may return null if the package is unknown or when there is no
* information on that particular package available.
* XXX - Since ClassLoader.getPackage() is not yet implemented it just
* returns null.
* @param name the name of the desired package
*/
public static Package getPackage(String name) {
return null;
}
/**
* Returns all the packages that are known to the callers class loader.
* XXX - Since ClassLoader.getPackages() is not yet implemented it just
* returns null.
*/
public static Package[] getPackages() {
return null;
}
/**
* Returns the hashCode of the name of this package.
*/
public int hashCode() {
return name.hashCode();
}
/**
* Returns a string representation of this package name, specification,
* implementation and class origin if sealed.
*/
public String toString() {
return "package: " + name +
" spec: " + specTitle +
" version: " + specVersion +
" vendor: " + specVendor +
" implementation: " + implTitle +
" version: " + implVersion +
" vendor: " + implVendor +
" sealed: " + sealed;
}
}