class .this

   今天研究下JDK源代码,发现tools.jar中javac包下的Mian方法竟然有 Main.this..用法,百思不得其解,于是网上查找了资料,编辑了下发下。。。。

     有时候,我们会用到一些内部类和匿名类。当在匿名类中用this时(this.方法名)这个this则指的是匿名类或内部类本身。这时如果我们要使用外部类的方法和变量的话,则应该加上外部类的类名(外部类名.this.方法名)。如下面这个例子(一些代码省略了,如异常处理):  
public class Demo{  
        public Demo() {  
        Thread thread = new Thread() {  
              public void run() {  
              Demo.this.run();//调用外部类的run方法,输出 "外部类"

              System.out.println("内部类");
        };  
     this.run();//调用内部类的run方法,输出 "外部类 内部类"

     thread.start();  
}  
   public void run() {  
        System.out.println("外部类");
   }  
}  
在上面这个例子中, thread是一个匿名类对象,在它的定义中,它的run函数里用到了外部类的run函数。这时由于函数同名,直接调用就不行了。这时有两种办法,一种就是把外部的 run 函数换一个名字,但这种办法对于一个开发到中途的应用来说是不可取的。那么就可以用这个例子中的办法用 外部类的类名加上this引用来说明要调用的是外部类的方法run。 

Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details. C:/Program Files/Java/jdk-1.8\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="D:/Android/sdk\tools" -Dfile.encoding=UTF8 -jar "D:\Unity\5.3.8f2\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" - stderr[ warning: Ignoring InnerClasses attribute for an anonymous inner class (com.tencent.mm.sdk.b.b) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.a.b) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.a.e) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.a.f) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.a.i) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.a.m) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.d.b.c) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.d.b.b) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.e.h) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. Uncaught translation error: java.lang.IllegalArgumentException: already added: Lbitter/jnibridge/JNIBridge; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lbitter/jnibridge/JNIBridge$a; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/NativeLoader; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/ReflectionHelper; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/ReflectionHelper$1; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/ReflectionHelper$a; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/UnityPlayer; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/UnityPlayer$1; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/UnityPlayer$10; UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.RuntimeException: Translation has been interrupted at com.android.dx.command.dexer.Main.processAllFiles(Main.java:608) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at SDKMain.main(SDKMain.java:129) Caused by: java.lang.InterruptedException: Too many errors at com.android.dx.command.dexer.Main.processAllFiles(Main.java:600) ... 9 more ] stdout[ processing bin\classes\.\com\dw\Dating\lua\R.class... processing bin\classes\.\com\dw\Dating\lua\R$attr.class... processing bin\classes\.\com\dw\Dating\lua\R$drawable.class... processing bin\classes\.\com\dw\Dating\lua\R$string.class... processing bin\classes\.\com\dw\Dating\lua\R$style.class... processing bin\classes\.\com\dw\Dating\lua\R$xml.class... processing archive bin\classes.jar... processing bitter/jnibridge/JNIBridge.class... processing bitter/jnibridge/JNIBridge$a.class... processing com/unity3d/player/NativeLoader.class... processing com/unity3d/player/ReflectionHelper.class... processing com/unity3d/player/ReflectionHelper$1.class... processing com/unity3d/player/ReflectionHelper$a.class... processing com/unity3d/player/UnityPlayer.class... processing com/unity3d/player/UnityPlayer$1.class... processing com/unity3d/player/UnityPlayer$10.class... processing com/unity3d/player/UnityPlayer$11.class... processing com/unity3d/player/UnityPlayer$12.class... processing com/unity3d/player/UnityPlayer$13.class... processing com/unity3d/player/UnityPlayer$14.class... processing com/unity3d/player/UnityPlayer$15.class... processing com/unity3d/player/UnityPlayer$15$1.class... processing com/unity3d/player/UnityPlayer$16.class... processing com/unity3d/player/UnityPlayer$17.class... processing com/unity3d/player/UnityPlayer$18.class... processing com/unity3d/player/UnityPlayer$19.class... processing com/unity3d/player/UnityPlayer$2.class... processing com/unity3d/player/UnityPlayer$20.class... processing com/unity3d/player/UnityPlayer$3.class... processing com/unity3d/player/UnityPlayer$4.class... processing com/unity3d/player/UnityPlayer$5.class... processing com/unity3d/player/UnityPlayer$6.class... processing com/unity3d/player/UnityPlayer$7.class... processing com/unity3d/player/UnityPlayer$8.class... processing com/unity3d/player/UnityPlayer$9.class... processing com/unity3d/player/UnityPlayer$a.class... processing com/unity3d/player/UnityPlayer$b.class... processing com/unity3d/player/UnityPlayer$c.class... processing com/unity3d/player/UnityPlayer$d.class... processing com/unity3d/player/UnityPlayerActivity.class... processing com/unity3d/player/UnityPlayerNativeActivity.class... processing com/unity3d/player/UnityPlayerProxyActivity.class... processing com/unity3d/player/UnityWebRequest.class... processing com/unity3d/player/WWW.class... processing com/unity3d/player/a.class... processing com/unity3d/player/a$1.class... processing com/unity3d/player/a$2.class... processing com/unity3d/player/a$a.class... processing com/unity3d/player/b.class... processing com/unity3d/player/b$1.class... processing com/unity3d/player/b$2.class... processing com/unity3d/player/c.class... processing com/unity3d/player/d.class... processing com/unity3d/player/d$1.class... processing com/unity3d/player/d$2.class... processing com/unity3d/player/e.class... processing com/unity3d/player/f.class... processing com/unity3d/player/g.class... processing com/unity3d/player/h.class... processing com/unity3d/player/i.class... processing com/unity3d/player/j.class... processing com/unity3d/player/k.class... processing com/unity3d/player/k$1.class... processing com/unity3d/player/k$2.class... processing com/unity3d/player/k$2$1.class... processing com/unity3d/player/k$2$1$1.class... processing com/unity3d/player/l.class... processing com/unity3d/player/l$1.class... processing com/unity3d/player/m.class... processing com/unity3d/player/n.class... processing com/unity3d/player/n$1.class... processing com/unity3d/player/o.class... processing com/unity3d/player/p.class... processing com/unity3d/player/p$1.class... processing com/unity3d/player/q.class... processing com/unity3d/player/r.class... processing com/unity3d/player/s.class... processing com/unity3d/player/s$1.class... processing com/unity3d/player/s$2.class... processing com/unity3d/player/s$3.class... processing com/unity3d/player/t.class... processing com/unity3d/player/u.class... processing com/unity3d/player/v.class... processing com/unity3d/player/w.class... processing com/unity3d/player/w$1.class... processing org/fmod/FMODAudioDevice.class... processing org/fmod/a.class... processing archive plugins\.\FanweiPlugin_v4.4.jar... processing android/app/ActivityThread.class... processing android/app/Instrumentation.class... processing android/app/Instrumentation$ActivityMonitor.class... processing android/app/Instrumentation$ActivityResult.class... processing android/app/LoadedApk.class... processing com/fanwei/bluearty/pluginmgr/BuildConfig.class... processing com/fanwei/bluearty/pluginmgr/DynamicActivity.class... processing com/fanwei/bluearty/pluginmgr/Globals.class... processing com/fanwei/bluearty/pluginmgr/PluginActivityLifeCycleCallback.class... processing com/fanwei/bluearty/pluginmgr/PluginManager.class... processing com/fanwei/bluearty/pluginmgr/delegate/DelegateActivityThread.class... processing com/fanwei/bluearty/pluginmgr/delegate/DelegateInstrumentation.class... processing com/fanwei/bluearty/pluginmgr/delegate/LayoutInflaterProxyContext.class... processing com/fanwei/bluearty/pluginmgr/environment/CreateActivityData.class... processing com/fanwei/bluearty/pluginmgr/environment/PlugInfo.class... processing com/fanwei/bluearty/pluginmgr/environment/PluginClassLoader.class... processing com/fanwei/bluearty/pluginmgr/environment/PluginContext.class... processing com/fanwei/bluearty/pluginmgr/environment/PluginInstrumentation.class... processing com/fanwei/bluearty/pluginmgr/reflect/NULL.class... processing com/fanwei/bluearty/pluginmgr/reflect/Reflect.class... processing com/fanwei/bluearty/pluginmgr/reflect/Reflect$1.class... processing com/fanwei/bluearty/pluginmgr/reflect/ReflectException.class... processing com/fanwei/bluearty/pluginmgr/selector/DefaultActivitySelector.class... processing com/fanwei/bluearty/pluginmgr/selector/DynamicActivitySelector.class... processing com/fanwei/bluearty/pluginmgr/utils/FileUtil.class... processing com/fanwei/bluearty/pluginmgr/utils/IntReader.class... processing com/fanwei/bluearty/pluginmgr/utils/NamespaceStack.class... processing com/fanwei/bluearty/pluginmgr/utils/PluginManifestUtil.class... processing com/fanwei/bluearty/pluginmgr/utils/StringBlock.class... processing com/fanwei/bluearty/pluginmgr/utils/Trace.class... processing com/fanwei/bluearty/pluginmgr/utils/XmlManifestReader.class... processing com/fanwei/bluearty/pluginmgr/utils/XmlResourceParser.class... processing com/fanwei/bluearty/pluginmgr/verify/PluginNotFoundException.class... processing com/fanwei/bluearty/pluginmgr/verify/PluginOverdueVerifier.class... processing com/fanwei/bluearty/pluginmgr/verify/SimpleLengthVerifier.class... processing com/fanwei/bluearty/pluginmgr/widget/LayoutInflaterWrapper.class... processing com/fanwei/bluearty/pluginmgr/widget/ViewStub.class... processing com/fanwei/bluearty/pluginmgr/widget/ViewStub$OnInflateListener.class... processing com/fanwei/bluearty/simplejson/BasicType.class... processing com/fanwei/bluearty/simplejson/BuildConfig.class... processing com/fanwei/bluearty/simplejson/SimpleJson.class... processing com/fanwei/bluearty/simplejson/SimpleJson$1.class... processing com/fanwei/bluearty/simplejson/annotation/CollectionCreateBy.class... processing com/fanwei/bluearty/simplejson/annotation/NickName.class... processing com/fanwei/bluearty/simplejson/annotation/NotConvert.class... processing com/fanwei/bluearty/simplejson/annotation/SerializeBy.class... processing com/fanwei/bluearty/simplejson/serializer/Serializer.class... processing com/fanwei/bluearty/tinyhttp/BuildConfig.class... processing com/fanwei/bluearty/tinyhttp/Const.class... processing com/fanwei/bluearty/tinyhttp/Request.class... processing com/fanwei/bluearty/tinyhttp/Request$Method.class... processing com/fanwei/bluearty/tinyhttp/Response.class... processing com/fanwei/bluearty/tinyhttp/RetryManager.class... processing com/fanwei/bluearty/tinyhttp/Webb.class... processing com/fanwei/bluearty/tinyhttp/Webb$1.class... processing com/fanwei/bluearty/tinyhttp/Webb$AutoDisconnectInputStream.class... processing com/fanwei/bluearty/tinyhttp/Webb$FWHostnameVerifier.class... processing com/fanwei/bluearty/tinyhttp/Webb$FWX509TrustManager.class... processing com/fanwei/bluearty/tinyhttp/WebbException.class... processing com/fanwei/bluearty/tinyhttp/WebbUtils.class... processing com/fanwei/jubaosdk/common/BuildConfig.class... processing com/fanwei/jubaosdk/common/core/AbstractCall.class... processing com/fanwei/jubaosdk/common/core/AbstractCall$Callback.class... processing com/fanwei/jubaosdk/common/core/AbstractCall$CallbackUI.class... processing com/fanwei/jubaosdk/common/core/AbstractCall$CallbackUI$UIHandler.class... processing com/fanwei/jubaosdk/common/core/Call.class... processing com/fanwei/jubaosdk/common/core/Dispatcher.class... processing com/fanwei/jubaosdk/common/core/OnPayResultListener.class... processing com/fanwei/jubaosdk/common/entity/Advertisement.class... processing com/fanwei/jubaosdk/common/entity/OrderEntity.class... processing com/fanwei/jubaosdk/common/entity/PayMethodResponse.class... processing com/fanwei/jubaos<message truncated>
最新发布
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值