Close

Java Reflection - Class.isSynthetic() Examples

Code Snippets Java Reflection Java 


Class:

java.lang.Class

java.lang.Objectjava.lang.Objectjava.lang.Classjava.lang.Classjava.io.SerializableSerializablejava.lang.reflect.GenericDeclarationGenericDeclarationjava.lang.reflect.TypeTypejava.lang.reflect.AnnotatedElementAnnotatedElementLogicBig

Method:

public boolean isSynthetic()

Returns true if this class is a synthetic class; returns false otherwise.


Examples


package com.logicbig.example.clazz;

import java.io.Serializable;

public class IsSyntheticExample {

public static void main(String... args) {
boolean b = Enum.class.isSynthetic();
System.out.println(b);

b = IsSyntheticExample.class.isSynthetic();
System.out.println(b);

b = new Serializable() {}.getClass().isSynthetic();
System.out.println(b);

Runnable runnable = () -> {};
b = runnable.getClass().isSynthetic();
System.out.println(b);
}
}

Output

false
false
false
true




See Also