public void defineProperty(String propertyName,Class<?> clazz,int attributes){
  int length=propertyName.length();
  if (length == 0)   throw new IllegalArgumentException();
  char[] buf=new char[3 + length];
  propertyName.getChars(0,length,buf,3);
  buf[3]=Character.toUpperCase(buf[3]);
  buf[0]='g';
  buf[1]='e';
  buf[2]='t';
  String getterName=new String(buf);
  buf[0]='s';
  String setterName=new String(buf);
  Method[] methods=FunctionObject.getMethodList(clazz);
  Method getter=FunctionObject.findSingleMethod(methods,getterName);
  Method setter=FunctionObject.findSingleMethod(methods,setterName);
  if (setter == null)   attributes|=ScriptableObject.READONLY;
  defineProperty(propertyName,null,getter,setter == null ? null : setter,attributes);
}

public void defineProperty ( String propertyName , Class < ? > clazz , int attributes ) { int length = propertyName . length ( ) ; if ( length == 0 ) throw new IllegalArgumentException ( ) ; char [ ] buf = new char [ 3 + length ] ; propertyName . getChars ( 0 , length , buf , 3 ) ; buf [ 3 ] = Character . toUpperCase ( buf [ 3 ] ) ; buf [ 0 ] = 'g' ; buf [ 1 ] = 'e' ; buf [ 2 ] = 't' ; String getterName = new String ( buf ) ; buf [ 0 ] = 's' ; String setterName = new String ( buf ) ; Method [ ] methods = FunctionObject . getMethodList ( clazz ) ; Method getter = FunctionObject . findSingleMethod ( methods , getterName ) ; Method setter = FunctionObject . findSingleMethod ( methods , setterName ) ; if ( setter == null ) attributes |= ScriptableObject . READONLY ; defineProperty ( propertyName , null , getter , setter == null ? null : setter , attributes ) ; }
define a javascript property with getter and setter side effects . if the setter is not found , the attribute readonly is added to the given attributes . < p > the getter must be a method with zero parameters , and the setter , if found , must be a method with one parameter . < p >
