@@ -127,6 +127,10 @@ static String desugarVarargs(String s) {
127
127
return s .trim ().endsWith ("..." ) ? s .trim ().substring (0 , s .length () - 3 ) + "[]" : s ;
128
128
}
129
129
130
+ static String filterJavaAnnotations (String s ) {
131
+ return s .contains ("@Deprecated" ) ? "@Deprecated " : "" ;
132
+ }
133
+
130
134
static String upcastMethodName (String javaName ) {
131
135
String shortName = javaName .substring (javaName .lastIndexOf ('.' ) + 1 );
132
136
return "as" + Character .toUpperCase (shortName .charAt (0 )) + shortName .substring (1 );
@@ -357,7 +361,7 @@ void containers(Context context, DeclarationList declList) throws ParserExceptio
357
361
if (dim < 2 && !javaName .equals ("int" ) && !javaName .equals ("long" )) {
358
362
decl .text += " public " + containerType .javaName + "(" + javaName + " value) { this(1); put(0, value); }\n " ;
359
363
}
360
- decl .text += " public " + containerType .javaName + "(" + javaName + arrayBrackets + " ... array) { this(array.length); put(array); }\n " ;
364
+ decl .text += " public " + containerType .javaName + "(" + desugarVarargs ( javaName ) + arrayBrackets + " ... array) { this(array.length); put(array); }\n " ;
361
365
}
362
366
} else if (indexType == null && dim == 0 && !constant && !purify ) {
363
367
int n = 0 ;
@@ -597,7 +601,7 @@ void containers(Context context, DeclarationList declList) throws ParserExceptio
597
601
+ " return put(0, value);\n "
598
602
+ " }\n " ;
599
603
}
600
- decl .text += " public " + containerType .javaName + " put(" + javaName + arrayBrackets + " ... array) {\n " ;
604
+ decl .text += " public " + containerType .javaName + " put(" + desugarVarargs ( javaName ) + arrayBrackets + " ... array) {\n " ;
601
605
String indent = " " , indices = "" , args = "" ;
602
606
separator = "" ;
603
607
for (int i = 0 ; i < dim ; i ++) {
@@ -2740,7 +2744,7 @@ boolean function(Context context, DeclarationList declList) throws ParserExcepti
2740
2744
}
2741
2745
}
2742
2746
if (type .constructor && params != null ) {
2743
- decl .text += "public " + context .shorten (context .javaName ) + dcl .parameters .list + " { super((Pointer)null); allocate" + params .names + "; }\n " +
2747
+ decl .text += filterJavaAnnotations ( type . annotations ) + "public " + context .shorten (context .javaName ) + dcl .parameters .list + " { super((Pointer)null); allocate" + params .names + "; }\n " +
2744
2748
type .annotations + "private native void allocate" + dcl .parameters .list + ";\n " ;
2745
2749
} else {
2746
2750
String modifiers2 = modifiers ;
@@ -3494,7 +3498,7 @@ String downcast(Type derived, Type base, boolean virtual) {
3494
3498
}
3495
3499
String shortName = derived .javaName .substring (derived .javaName .lastIndexOf ('.' ) + 1 );
3496
3500
String res = " /** Downcast constructor. */\n "
3497
- + " public " + shortName + "(" + base .javaName + " pointer) { super((Pointer)null); allocate(pointer); }\n " ;
3501
+ + " " + filterJavaAnnotations ( annotations ) + " public " + shortName + "(" + base .javaName + " pointer) { super((Pointer)null); allocate(pointer); }\n " ;
3498
3502
if (annotations .isEmpty ()) {
3499
3503
res += " @Namespace private native @Name(\" " + downcastType + "_cast<" + derived .cppName + "*>\" ) void allocate(" + base .javaName + " pointer);\n " ;
3500
3504
} else {
@@ -3931,7 +3935,7 @@ boolean group(Context context, DeclarationList declList) throws ParserException
3931
3935
3932
3936
if (implicitConstructor && (info == null || !info .purify ) && (!abstractClass || ctx .virtualize )) {
3933
3937
constructors += " /** Default native constructor. */\n " +
3934
- " public " + shortName + "() { super((Pointer)null); allocate(); }\n " ;
3938
+ " " + filterJavaAnnotations ( constructorAnnotations ) + " public " + shortName + "() { super((Pointer)null); allocate(); }\n " ;
3935
3939
if (constructorAnnotations .isEmpty ()) {
3936
3940
constructors += " /** Native array allocator. Access with {@link Pointer#position(long)}. */\n " +
3937
3941
" public " + shortName + "(long size) { super((Pointer)null); allocateArray(size); }\n " ;
0 commit comments