apple/pkl · error · JavaCodeGeneratorException

Standard library class

Error message

Standard library class `${pClass.qualifiedName}` is not supported by Java code generator. If you think this is an omission, please let us know.

What it means

Standard-library Pkl classes other than the explicitly mapped ones (Regex, Version, etc.) cannot be translated to Java types, so toJavaPoetName throws. The message invites filing an issue since the omission may just be unmapped support.

Solutions

  1. Change the Pkl property type to a supported class (String, Int, Duration, DataSize, Regex, Version, collections, etc.).
  2. Upgrade the pkl-codegen-java version — newer versions map more stdlib classes.
  3. Wrap or replace the exotic stdlib type with your own class.
  4. File an upstream issue asking for the class to be mapped, as the message suggests.

Example fix

// before (Pkl)
ids: IntSeq
// after
ids: List<Int>
Defensive patterns

Strategy: validation

Validate before calling

fun isMappedStdlibClass(c: PClass) = c.isStandardLibraryClass && c.qualifiedName in setOf("pkl.base#Regex","pkl.base#Version")

Try / catch

try { generate() } catch (e: JavaCodeGeneratorException) { if ("Standard library class" in e.message!! && "not supported" in e.message!!) replaceType() else throw e }

Prevention

When it happens

Trigger: A generated schema contains a property whose type is a stdlib class (e.g. some pkl.base or pkl.collection class not in the mapping table) — PClassInfo that isStandardLibraryClass and not one of the handled cases.

Common situations: Using less-common pkl.base classes (e.g. IntSeq, List/Map exotic usages beyond mapped ones) or newer stdlib classes introduced before the generator added mappings.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08). Data as JSON: /api/errors/b316fb3d120a69e8. Report an issue: GitHub.

Appendix: source

Thrown at pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/JavaCodeGenerator.kt:847

                } else {
                  typeArguments[0].toJavaPoetTypeArgumentName()
                },
                if (typeArguments.isEmpty()) {
                  OBJECT
                } else {
                  typeArguments[1].toJavaPoetTypeArgumentName()
                },
              )
              .nullableIf(nullable)
          PClassInfo.Module -> PMODULE.nullableIf(nullable)
          PClassInfo.Class -> PCLASS.nullableIf(nullable)
          PClassInfo.Regex -> PATTERN.nullableIf(nullable)
          PClassInfo.Version -> VERSION.nullableIf(nullable)
          else ->
            when {
              !classInfo.isStandardLibraryClass -> pClass.toJavaPoetName().nullableIf(nullable)
              else ->
                throw JavaCodeGeneratorException(
                  "Standard library class `${pClass.qualifiedName}` is not supported by Java code generator. " +
                    "If you think this is an omission, please let us know."
                )
            }
        }
      }
      is PType.Nullable -> baseType.toJavaPoetName(nullable = true, boxed = true)
      is PType.Constrained -> baseType.toJavaPoetName(nullable = nullable, boxed = boxed)
      is PType.Alias ->
        when (typeAlias.qualifiedName) {
          "pkl.base#NonNull" -> OBJECT.nullableIf(nullable)
          "pkl.base#Int8" -> TypeName.BYTE.boxIf(boxed).nullableIf(nullable)
          "pkl.base#Int16",
          "pkl.base#UInt8" -> TypeName.SHORT.boxIf(boxed).nullableIf(nullable)
          "pkl.base#Int32",
          "pkl.base#UInt16" -> TypeName.INT.boxIf(boxed).nullableIf(nullable)
          "pkl.base#UInt",
          "pkl.base#UInt32" -> TypeName.LONG.boxIf(boxed).nullableIf(nullable)

View on GitHub (pinned to f3efcbfc9b)