Michael Beck wrote: > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > Sent: Monday, October 22, 2001 06:06 > > > Every implementation of the Java language contains the > > non-abstract class > > java.util.Properties, which does in fact implement all the methods of > > Dictionary. > > So let us suppose that I create a class > > com.acunia.AcuniaProperties which > > extends java.util.Properties, and that this is packaged > > together with some > > other classes in a .jar file. I then hand this over to our > > sales force, who are > > liable to use it in a customer demonstration. I have no way > > of knowing whether > > they will demonstrate it running on our own VM (Wonka), IBM's > > J9, Kaffe (as a component of Pocket Linux), HP's Chai, something > > licensed from Sun's pJava, > > or something I've never even heard of. Can it really be that > > by creating my > > little class I have actually changed the design blueprints of > > products from > > four different companies, without even knowing it? > > I would distinguish here between creating a derived class, and using a > particular implementation of the original class' interface at the run-time. > > I would assume that you don't extend a class in a vacuum, i.e. that you take an > actual java.util.Properties class and extend it.
I would argue that this assumption is incorrect. Take the attached source for Provider.java as an example: all that my colleague needed in order to write that was to know that java.util.Properties has methods load, get, put, and remove, which can be overridden. He didn't need to `take an actual java.util.Properties class' in order to write what he did. > If the author gives you the > right to create derived classes, then you are OK. There is no author, because there is no class. > > Now comes the "use" of particular class at the run-time. It would seem to me > that at this moment you can use any concrete class, as long as the author gives > you the right to create derived classes, i.e. if Kaffe, Chai, and J9 give you > the right to derive new classes, you can use anyone of them, even if you > originally created the inherited class from Kaffe's java.util.Properties. The only class not derived from another class is java.lang.Object. A class library which does not allow derived classes is useless. > Or you can (if possible in Java) compile a file with the original class you have > used, so the program doesn't have to look for it, but uses the one provided by > you. A good implementation will barf on that. If you can supply your own java.util.Properties then you can undermine the whole security framework. But that's another topic. :) Regards Chris
/************************************************************************** * Copyright (c) 2001 by Acunia N.V. All rights reserved. * * * * This software is copyrighted by and is the sole property of Acunia N.V. * * and its licensors, if any. All rights, title, ownership, or other * * interests in the software remain the property of Acunia N.V. and its * * licensors, if any. * * * * This software may only be used in accordance with the corresponding * * license agreement. Any unauthorized use, duplication, transmission, * * distribution or disclosure of this software is expressly forbidden. * * * * This Copyright notice may not be removed or modified without prior * * written consent of Acunia N.V. * * * * Acunia N.V. reserves the right to modify this software without notice. * * * * Acunia N.V. * * Vanden Tymplestraat 35 [EMAIL PROTECTED] * * 3000 Leuven http://www.acunia.com * * Belgium - EUROPE * **************************************************************************/ /* ** $Id: Provider.java,v 1.3 2001/09/04 14:59:14 oberfeld Exp $ */ package java.security; import java.util.*; import java.io.*; public abstract class Provider extends Properties{ private String info; private String name; private double version; protected Provider(String name, double version, String info){ this.info = info; this.name = name; this.version = version; } public String getInfo(){ return info; } public String getName(){ return name; } public double getVersion(){ return version; } public String toString() { return name+" version: "+version; } public Set entrySet(){ return Collections.unmodifiableSet(super.entrySet()); } public Set keySet(){ return Collections.unmodifiableSet(super.keySet()); } public Collection values(){ return Collections.unmodifiableCollection(super.values()); } public void clear() { SecurityManager sm = System.getSecurityManager(); if (sm!=null) { sm.checkSecurityAccess("clearProviderProperties."+name); } super.clear(); } public void load(InputStream in) throws IOException { super.load(in); } public Object put(Object key, Object value) { SecurityManager sm = System.getSecurityManager(); if (sm!=null) { sm.checkSecurityAccess("putProviderProperty."+name); } return super.put(key,value); } public void putAll(Map t){ SecurityManager sm = System.getSecurityManager(); if (sm!=null) { sm.checkSecurityAccess("putProviderProperty."+name); } Iterator it = t.entrySet().iterator(); while (it.hasNext()){ Map.Entry me = (Map.Entry)it.next(); super.put(me.getKey(),me.getValue()); } } public Object remove(Object key) { SecurityManager sm = System.getSecurityManager(); if (sm!=null) { sm.checkSecurityAccess("removeProviderProperty."+name); } return super.remove(key); } }