{"record":{"id":"7dcae629800de985","repo":"pinpoint-apm/pinpoint","slug":"transformer-already-exist-classname-classintern","errorCode":null,"errorMessage":"Transformer already exist. className:${classInternalName} new:${transformer.getClass()} old:${old.getClass()}","messagePattern":"Transformer already exist\\. className:(.+?) new:(.+?) old:(.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/transformer/DefaultTransformerRegistry.java","lineNumber":97,"sourceCode":"            final ClassNameMatcher classNameMatcher = (ClassNameMatcher) matcher;\n            String className = classNameMatcher.getClassName();\n            addModifier0(registry, transformer, className);\n        } else if (matcher instanceof MultiClassNameMatcher) {\n            final MultiClassNameMatcher classNameMatcher = (MultiClassNameMatcher) matcher;\n            List<String> classNameList = classNameMatcher.getClassNames();\n            for (String className : classNameList) {\n                addModifier0(registry, transformer, className);\n            }\n        } else {\n            throw new IllegalArgumentException(\"unsupported matcher :\" + matcher);\n        }\n    }\n\n    private void addModifier0(Map<String, ClassFileTransformer> registry, ClassFileTransformer transformer, String className) {\n        final String classInternalName = JavaAssistUtils.javaNameToJvmName(className);\n        final ClassFileTransformer old = registry.put(classInternalName, transformer);\n        if (old != null) {\n            throw new IllegalStateException(\"Transformer already exist. className:\" + classInternalName + \" new:\" + transformer.getClass() + \" old:\" + old.getClass());\n        }\n    }\n}","sourceCodeStart":79,"sourceCodeEnd":100,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/transformer/DefaultTransformerRegistry.java#L79-L100","documentation":"addModifier0() stores transformers in a map keyed by class internal name; the registry enforces a strict one-transformer-per-class rule, throwing IllegalStateException when a second transformer tries to claim the same class. This prevents silent transformer chaining/ordering bugs.","triggerScenarios":"Calling addTransformer() for the same target class internal name twice — e.g. two plugins instrumenting the same class, or the same plugin registered twice.","commonSituations":"Two Pinpoint plugins both targeting e.g. com.mysql.jdbc.Connection; duplicate plugin jar on the agent classpath; profile type config causing a base plugin and an optional plugin to load together.","solutions":["Remove one of the duplicate plugin jars or disable one plugin targeting the class in the profiler config","Ensure plugins are only loaded once (check the agent plugin directory for duplicates)","Merge the two instrumentation targets into a single transformer if both must modify the class"],"exampleFix":"// before (two jars targeting the same class)\nplugins: my-plugin.jar, other-plugin.jar // both target com.example.Foo\n// after\nplugins: my-plugin.jar // keep only one transformer per target class","handlingStrategy":"validation","validationCode":"Set<String> claimed = new HashSet<>();\nfor (String cn : matcherClassNames) {\n    String internal = JavaAssistUtils.javaNameToJvmName(cn);\n    if (!claimed.add(internal)) throw new IllegalStateException(\"duplicate transformer target: \" + internal);\n}","typeGuard":null,"tryCatchPattern":"try {\n    registry.addTransformer(transformer, matcher);\n} catch (IllegalStateException e) {\n    logger.error(\"Duplicate transformer registration: {}\", e.getMessage());\n}","preventionTips":["Keep a manifest of which plugin targets which class","Audit the plugins directory for duplicate jars","Disable one of two plugins that instrument the same class","Merge instrumentation into a single transformer when possible"],"tags":["bytecode-instrumentation","duplicate-registration","class-transformer"],"backgroundTag":"file-already-exists","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}