diff options
author | jfrijters <jfrijters> | 2013-02-20 00:00:32 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2013-02-20 00:00:32 +0400 |
commit | b757b8fa58d71ae9b3dbde798e98f3f9b6983c0a (patch) | |
tree | 2c812dd38e514dc6e701c86cbcc46b0b8ad34e8f | |
parent | 1e8df89fdc494ae05d4523c5bb51f81a09f611ab (diff) |
Replace CheckDefineClassAllowed() with a call to FindLoadedClassLazy().
-rw-r--r-- | runtime/AssemblyClassLoader.cs | 13 | ||||
-rw-r--r-- | runtime/ClassLoaderWrapper.cs | 27 |
2 files changed, 15 insertions, 25 deletions
diff --git a/runtime/AssemblyClassLoader.cs b/runtime/AssemblyClassLoader.cs index c8b97795..68ca3941 100644 --- a/runtime/AssemblyClassLoader.cs +++ b/runtime/AssemblyClassLoader.cs @@ -959,18 +959,9 @@ namespace IKVM.Internal } #endif - protected override void CheckDefineClassAllowed(string className) + protected override TypeWrapper FindLoadedClassLazy(string name) { - if (DoLoad(className) != null) - { - throw new LinkageError("duplicate class definition: " + className); - } - } - - protected override TypeWrapper FindLoadedClassImpl(string name) - { - return base.FindLoadedClassImpl(name) - ?? DoLoad(name) + return DoLoad(name) ?? FindOrLoadGenericClass(name, true); } diff --git a/runtime/ClassLoaderWrapper.cs b/runtime/ClassLoaderWrapper.cs index 91b515a1..95f5f55a 100644 --- a/runtime/ClassLoaderWrapper.cs +++ b/runtime/ClassLoaderWrapper.cs @@ -181,17 +181,17 @@ namespace IKVM.Internal { return FindOrLoadArrayClass(name, true); } - return FindLoadedClassImpl(name); - } - - protected virtual TypeWrapper FindLoadedClassImpl(string name) - { - lock(types) + TypeWrapper tw; + lock (types) { - TypeWrapper tw; types.TryGetValue(name, out tw); - return tw; } + return tw ?? FindLoadedClassLazy(name); + } + + protected virtual TypeWrapper FindLoadedClassLazy(string name) + { + return null; } internal TypeWrapper RegisterInitiatingLoader(TypeWrapper tw) @@ -307,11 +307,6 @@ namespace IKVM.Internal } #endif // !STATIC_COMPILER && !STUB_GENERATOR - protected virtual void CheckDefineClassAllowed(string className) - { - // this hook exists so that AssemblyClassLoader can prevent DefineClass when the name is already present in the assembly - } - #if !STUB_GENERATOR internal TypeWrapper DefineClass(ClassFile f, ProtectionDomain protectionDomain) { @@ -339,7 +334,11 @@ namespace IKVM.Internal return RegisterInitiatingLoader(tw); } #endif - CheckDefineClassAllowed(f.Name); + // check if the class already exists if we're an AssemblyClassLoader + if(FindLoadedClassLazy(f.Name) != null) + { + throw new LinkageError("duplicate class definition: " + f.Name); + } TypeWrapper def; try { |