as3commons-bytecode 获取全部类的一个BUG

下载了这个swc,号称能够反射出全部加载的类。已经用在了spring。spring

但是一运行就报错,说bytearray.uncompress出错。操。app

下载整个源码,单独加载as3commons-bytecode, 又发现边用不了,依赖了一个logging,还用了CONFIG::debug这种,估计和编译器参数绑定了。ui

删除全部的logging以后,调试,发现如下代码:debug

ReflectionDeserializer调试

		public function read(typeCache:ByteCodeTypeCache, input:ByteArray, applicationDomain:ApplicationDomain=null, isLoaderBytes:Boolean=true):void {
			_applicationDomain = applicationDomain ||= Type.currentApplicationDomain;
			_byteStream = AbcSpec.newByteArray();
			input.endian = Endian.LITTLE_ENDIAN;
			var swfIdentifier:String = input.readUTFBytes(3);
			var compressed:Boolean = (swfIdentifier == SWFWeaverFileIO.SWF_SIGNATURE_COMPRESSED);
			var version:uint = input.readByte();
			var filesize:uint = input.readUnsignedInt();

			input.readBytes(_byteStream);
			if (isLoaderBytes) {
				_byteStream.length -= 8;
			}

			if (compressed) {
				_byteStream.uncompress();
			}
			_byteStream.position = 0;
			readHeader(_byteStream);
			while (_byteStream.bytesAvailable) {
				readTags(typeCache, _byteStream);
			}
		}

  能够看到 uncompress以前,作了一个length -= 8code

这里是过滤掉头的3个byte = swfid, 1个byte的version,4个byte的filesize。blog

可是你码为何修改length。直接致使解压出错。这玩意到底有没有人用过的。因而我修改源码:input

			input.readBytes(_byteStream);
			if (isLoaderBytes) {
//				_byteStream.length -= 8;
			}

			if (compressed) {
				_byteStream.position = 0;
				_byteStream.uncompress();
			}

  注释掉length,同时修改position=0.编译器

一切正常了。源码

的确能够反射出全部的类,是读bytecode得到的,比bytearray得SwfExplorer好。就是这个地方不知道做者怎么搞的。

相关文章
相关标签/搜索