Skip to content

Error when creating ScanResult from JSON #682

@thibaultmeyer

Description

@thibaultmeyer

Hello,

I get an error when I try to restore a ScanResult from JSON.

Environment

ClassGraph version : 4.8.146

openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

Creating JSON

new ClassGraph()
    .acceptPackages("*")
    .addClassLoader(classLoader)
    .enableAnnotationInfo()
    .enableMethodInfo()
    .scan()
    .toJSON()

Loading JSON

ScanResult.fromJSON(content);

Error

Exception in thread "main" java.lang.IllegalArgumentException: Class io.github.classgraph.Classfile$MethodTypeAnnotationDecorator does not have an accessible default (no-arg) constructor
	at nonapi.io.github.classgraph.json.ClassFieldCache.getDefaultConstructorForConcreteTypeOf(ClassFieldCache.java:215)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:371)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:601)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:601)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:601)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:601)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:601)
	at nonapi.io.github.classgraph.json.JSONDeserializer.deserializeObject(JSONDeserializer.java:680)
	at nonapi.io.github.classgraph.json.JSONDeserializer.deserializeObject(JSONDeserializer.java:707)
	at io.github.classgraph.ScanResult.fromJSON(ScanResult.java:1449)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions