Fix support for 'class' properties in Java codegen (#4237)

* Fix support for 'class' properties in Java codegen

Currently Java codegen works successfully for property named 'class' but
fails on '_class', '__class', etc, because of 'Object.getClass()'
overloading.

This fix is intended to avoid all Object method overloading cases.

* Regenerated samples for Java petstore-security-test
This commit is contained in:
menchauser
2016-11-22 20:18:40 +04:00
committed by wing328
parent 4e2c037e21
commit 6ebc2fc051
41 changed files with 1040 additions and 636 deletions

View File

@@ -361,7 +361,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// sanitize name
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
if ("class".equals(name.toLowerCase())) {
if (name.toLowerCase().matches("^_*class$")) {
return "propertyClass";
}