Thrift: creating a char array for Java

According to the topic about Strings and security in java , the type String

can be dangerous when used for password attributes mainly because strings are immutable (can be found in the VM image) and can be registered.

How do I use Thrift to generate Java classes, is there a thrift type or parameter that can generate an array char []

(char) so that I can avoid directly manipulating the generated Java classes?

+3


source to share


2 answers


Not a char array ... but you can approach IDL like this:

namespace java array.test

struct Test {
  1:  list<byte> passwd;
  2:  binary passwd2;
}

      

list<byte>

will generate the field java.util.List<Byte>

in Java.



binary

will generate the field java.nio.ByteBuffer

in Java.

I think you should be able to effectively exclude any of these from them in order to achieve what is described in your linked question.

+1


source


This is what it says thrift --help

for Java:

  java (Java):
    beans:           Members will be private, and setter methods will return void.
    private-members: Members will be private, but setter methods will return 'this' like usual.
    nocamel:         Do not use CamelCase field accessors with beans.
    fullcamel:       Convert underscored_accessor_or_service_names to camelCase.
    android:         Generated structures are Parcelable.
    android_legacy:  Do not use java.io.IOException(throwable) (available for Android 2.3 and above).
    option_type:     Wrap optional fields in an Option type.
    java5:           Generate Java 1.5 compliant code (includes android_legacy flag).
    reuse-objects:   Data objects will not be allocated, but existing instances will be used (read and write).
    sorted_containers:
                     Use TreeSet/TreeMap instead of HashSet/HashMap as a implementation of set/map.

      



So the answer is: Currently not .

0


source







All Articles