jaxws/src/share/classes/com/sun/codemodel/internal/JCodeModel.java
changeset 2678 57cf2a1c1a05
parent 8 474761f14bca
equal deleted inserted replaced
2225:a25c5ec5e40e 2678:57cf2a1c1a05
     1 /*
     1 /*
     2  * Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
     2  * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Sun designates this
     7  * published by the Free Software Foundation.  Sun designates this
   444                     break;
   444                     break;
   445             }
   445             }
   446 
   446 
   447             JClass clazz = ref(s.substring(start,idx));
   447             JClass clazz = ref(s.substring(start,idx));
   448 
   448 
       
   449             return parseSuffix(clazz);
       
   450         }
       
   451 
       
   452         /**
       
   453          * Parses additional left-associative suffixes, like type arguments
       
   454          * and array specifiers.
       
   455          */
       
   456         private JClass parseSuffix(JClass clazz) throws ClassNotFoundException {
   449             if(idx==s.length())
   457             if(idx==s.length())
   450                 return clazz; // hit EOL
   458                 return clazz; // hit EOL
   451 
   459 
   452             char ch = s.charAt(idx);
   460             char ch = s.charAt(idx);
   453 
   461 
   454             if(ch=='<')
   462             if(ch=='<')
   455                 return parseArguments(clazz);
   463                 return parseSuffix(parseArguments(clazz));
       
   464 
       
   465             if(ch=='[') {
       
   466                 if(s.charAt(idx+1)==']') {
       
   467                     idx+=2;
       
   468                     return parseSuffix(clazz.array());
       
   469                 }
       
   470                 throw new IllegalArgumentException("Expected ']' but found "+s.substring(idx+1));
       
   471             }
   456 
   472 
   457             return clazz;
   473             return clazz;
   458         }
   474         }
   459 
   475 
   460         /**
   476         /**