Eclipse warning about synthetic accessor for private static nested classes in Java?

后端 未结 6 1224
死守一世寂寞
死守一世寂寞 2020-12-03 02:17

My coworker suggested making several of the Eclipse code-formatting and warning settings to be more rigorous. The majority of these changes make sense, but I get this one we

6条回答
  •  爱一瞬间的悲伤
    2020-12-03 03:10

    You can not instantiate InnerClass from WeirdInnerClassJavaWarning. It's private, JVM wouldn't let you to, but the Java language (for some reason) would.

    Therefore, javac would make an additional method in InnerClass that would just return new InnerClass(), therefore permitting you to create InnerClass instances from WeirdInnerClassJavaWarning.

    i don't think you really need to get rid of it because the perfomance drop would be inmeasureably tiny. However, you can if you really want to.

提交回复
热议问题