Sadly, we where told to not push forward any heavy changes into Java - this way idea of limiting inheritance was reduced to making inheritance scope of interfaces final.
Then it turned out that there was 0% chance that any change requiring extended consulations would make it - basically already prepared/aproved projects will be selected.
I still have my draft of the: Final interfaces... proposal so it can be compared:
interface final Interface allow ClassI
sealed interface Service permits Car, Truck
Earlier, consideration across language was between final and scope limitation - not really secure enough solution for me.
public abstract class AccessCore{
protected AccessCore(){
if (this instanceof FirstAllowedClass){
...
} else if (this instanceof SecondAllowedClass){
...
} else{
throw new RuntimException(this.getClass().getSimpleName()+" was not supposed to extend "+AccessCore.class.getSimpleName());
}
}
}
public abstract class AccessCore{
private static final AccessKey accessKey;
static {
accessKey = new AccessKey();
Conditions.registerAccessKey(accessKey);
try {
{
final Class<?> forName = Class.forName( "core.data.conditions.instances.Tests4Conditions" );
final Method method = forName.getMethod("registerAccessKey", AccessKey.class);
method.invoke(null, accessKey);
}
} catch (ClassNotFoundException|IllegalAccessException|IllegalArgumentException|InvocationTargetException|NoSuchMethodException|SecurityException e) {
}
protected AccessCore(AccessKey accessKey) {
if (AccessCore.accessKey != accessKey) {//
throw new IllegalArgumentException(AccessKey.class.getSimpleName() + ": " + accessKey);
}
}
}
0 comments / komentarz(y):
Post a Comment