diff --git a/stubgenj/_stubgenj.py b/stubgenj/_stubgenj.py index d3d2cc9e7f0af0b025cef60a854a8fae6d065847..59aa1b0e1868cb231f766cd48385a93bd5e99187 100644 --- a/stubgenj/_stubgenj.py +++ b/stubgenj/_stubgenj.py @@ -1111,10 +1111,11 @@ def jpypeCustomizerSuperTypes(jClass: jpype.JClass, classTypeVars: List[TypeVarS typeStr += '[' + ', '.join([tv.pythonName for tv in classTypeVars]) + ']' extraSuperTypes.append(typeStr) customizersUsed.add(customizer) - if jClass.class_.getName() == 'java.lang.Throwable': + if jClass.class_.getName() == 'java.lang.Throwable' and 'jpype.JException' not in extraSuperTypes: # Workaround to allow Throwable-derived exception types be recognized # as JException, so that they can be assigned as Exception.__cause__ extraSuperTypes.append('jpype.JException') + customizersUsed.add(jpype.JException) return extraSuperTypes