Posts

Showing posts with the label AbstractExecutorService

What is Java Synthetic Field (ACC_SYNTHETIC)? with the example of AbstractExecutorService.$assertionsDisabled in java package java.util.concurrent

Image
A Java field in .class file marked with the ACC_SYNTHETIC flag to indicate that it was generated by a compiler and does not appear in source code . Binary Code is always the best document, so let's inspect an example of this case, from the class AbstractExecutorService ( source code ) in the package java.util.concurrent . The UML generated form the AbstractExecutorService.class file indicates it contains a field named $assertionsDisabled , and the detailed inspection shows this field is generated by compiler, since its "Access Flags" contains the value synthetic , which means this field "not present in the source code". UML diagram generated from AbstractExecutorService.class   Details page for the field AbstractExecutorService.$assertionsDisabled So why Java compiler is generating this field? Let's continue to inspect the field AbstractExecutorService.$assertionsDisabled . From the .class binary data analysis, the field Abstract...