test/tools/javac/boxing/BoxingCaching.java

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 4990346
  27  * @summary Verify autoboxed values are cached as required.
  28  * @author Joseph D. Darcy
  29  *
  30  * @compile -source 1.5 BoxingCaching.java
  31  * @run main BoxingCaching
  32  */
  33 
  34 public class BoxingCaching {
  35 
  36     static boolean verifyBooleanCaching() {
  37         boolean cached = true;
  38 
  39         Boolean results[] = new Boolean[2];
  40 
  41         results[0] = false;
  42         results[1] = true;
  43 
  44         Boolean B;
  45 
  46         B = false;
  47         if (B != results[0]) {
  48                 cached = false;
  49                 System.err.println("Boolean value " + B +
  50                                    " is not cached appropriately.");
  51         }




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 4990346
  27  * @summary Verify autoboxed values are cached as required.
  28  * @author Joseph D. Darcy



  29  */
  30 
  31 public class BoxingCaching {
  32 
  33     static boolean verifyBooleanCaching() {
  34         boolean cached = true;
  35 
  36         Boolean results[] = new Boolean[2];
  37 
  38         results[0] = false;
  39         results[1] = true;
  40 
  41         Boolean B;
  42 
  43         B = false;
  44         if (B != results[0]) {
  45                 cached = false;
  46                 System.err.println("Boolean value " + B +
  47                                    " is not cached appropriately.");
  48         }