alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (BytecodeInterface8.java)

This example Groovy source code file (BytecodeInterface8.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

bytecodeinterface8, bytecodeinterface8, object, object, throwable, throwable

The Groovy BytecodeInterface8.java source code

/*
 * Copyright 2003-2010 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.codehaus.groovy.runtime;

import org.codehaus.groovy.runtime.metaclass.DefaultMetaClassInfo;

/**
 * This class contains methods special to optimizations used directly from bytecode in Groovy 1.8
 * @author <a href="mailto:blackdrag@gmx.org">Jochen "blackdrag" Theodorou
 */
public class BytecodeInterface8 {
    
    public static boolean disabledStandardMetaClass() {
        return DefaultMetaClassInfo.disabledStandardMetaClass();
    }
    
    // ------------------ int ------------------
    
    /**
     * @return true if integer has its default MetaClass
     */
    public static boolean isOrigInt(){
       return DefaultMetaClassInfo.isOrigInt(); 
    }

    // ------------------ int[] ------------------
    
    /**
     * @return true if integer array has its default MetaClass
     */
    public static boolean isOrigIntArray(){
       return DefaultMetaClassInfo.isOrigIntArray(); 
    }
    
    
    /**
     * get value from int[] using normalized index
     */
    public static int intArrayGet(int[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
    
    /**
     * set value from int[] using normalized index
     */
    public static void intArraySet(int[] a, int i, int v) {
        try {
            a[i]=v;
        } catch (Throwable t) {
            a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)]=v;
        }
    }
    
    // ------------------ byte ------------------
    
    /**
     * @return true if byte has its default MetaClass
     */
    public static boolean isOrigB(){
       return false; 
    }

    // ------------------ byte[] ------------------
    
    /**
     * @return true if byte array has its default MetaClass
     */
    public static boolean isOrigBArray(){
       return false; 
    }
    
    
    /**
     * get value from byte[] using normalized index
     */
    public static byte bArrayGet(byte[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
    
    /**
     * set value from byte[] using normalized index
     */
    public static void bArraySet(byte[] a, int i, byte v) {
        try {
            a[i]=v;
        } catch (Throwable t) {
            a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)]=v;
        }
    }
    
    // ------------------ short ------------------
    
    /**
     * @return true if short has its default MetaClass
     */
    public static boolean isOrigS(){
       return false; 
    }

    // ------------------ short[] ------------------
    
    /**
     * @return true if short array has its default MetaClass
     */
    public static boolean isOrigSArray(){
       return false; 
    }
    
    
    /**
     * get value from short[] using normalized index
     */
    public static short sArrayGet(short[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
    
    /**
     * set value from short[] using normalized index
     */
    public static void sArraySet(short[] a, int i, short v) {
        try {
            a[i]=v;
        } catch (Throwable t) {
            a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)]=v;
        }
    }
    
    // ------------------ char ------------------
    
    /**
     * @return true if char has its default MetaClass
     */
    public static boolean isOrigC(){
       return false; 
    }

    // ------------------ char[] ------------------
    
    /**
     * @return true if char array has its default MetaClass
     */
    public static boolean isOrigCArray(){
       return false; 
    }
    
    
    /**
     * get value from char[] using normalized index
     */
    public static char cArrayGet(char[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
    
    /**
     * set value from char[] using normalized index
     */
    public static void cArraySet(char[] a, int i, char v) {
        try {
            a[i]=v;
        } catch (Throwable t) {
            a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)]=v;
        }
    }
    
    // ------------------ long ------------------
    
    /**
     * @return true if long has its default MetaClass
     */
    public static boolean isOrigL(){
       return false; 
    }

    // ------------------ long[] ------------------
    
    /**
     * @return true if long array has its default MetaClass
     */
    public static boolean isOrigLArray(){
       return false; 
    }
    
    
    /**
     * get value from long[] using normalized index
     */
    public static long lArrayGet(long[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
    
    /**
     * set value from long[] using normalized index
     */
    public static void lArraySet(long[] a, int i, long v) {
        try {
            a[i]=v;
        } catch (Throwable t) {
            a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)]=v;
        }
    }
    
    // ------------------ boolean ------------------
    
    /**
     * @return true if boolean has its default MetaClass
     */
    public static boolean isOrigZ(){
       return false; 
    }

    // ------------------ boolean[] ------------------
    
    /**
     * @return true if boolean array has its default MetaClass
     */
    public static boolean isOrigZArray(){
       return false; 
    }
    
    /**
     * get value from boolean[] using normalized index
     */
    public static boolean zArrayGet(boolean[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
    
    /**
     * set value from boolean[] using normalized index
     */
    public static void zArraySet(boolean[] a, int i, boolean v) {
        try {
            a[i]=v;
        } catch (Throwable t) {
            a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)]=v;
        }
    }
    
    // ------------------ float ------------------
    
    /**
     * @return true if float has its default MetaClass
     */
    public static boolean isOrigF(){
       return false; 
    }

    // ------------------ float[] ------------------
    
    /**
     * @return true if float array has its default MetaClass
     */
    public static boolean isOrigFArray(){
       return false; 
    }
    
    /**
     * get value from float[] using normalized index
     */
    public static float fArrayGet(float[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
    
    /**
     * set value from float[] using normalized index
     */
    public static void fArraySet(float[] a, int i, float v) {
        try {
            a[i]=v;
        } catch (Throwable t) {
            a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)]=v;
        }
    }
    
    // ------------------ double ------------------
    
    /**
     * @return true if double has its default MetaClass
     */
    public static boolean isOrigD(){
       return false; 
    }

    // ------------------ double[] ------------------
    
    /**
     * @return true if double array has its default MetaClass
     */
    public static boolean isOrigDArray(){
       return false; 
    }
    
    /**
     * get value from double[] using normalized index
     */
    public static double dArrayGet(double[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
    
    /**
     * set value from double[] using normalized index
     */
    public static void dArraySet(double[] a, int i, double v) {
        try {
            a[i]=v;
        } catch (Throwable t) {
            a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)]=v;
        }
    }
    
    // ------------------ Object[] ------------------
    public static Object objectArrayGet(Object[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
    
    /**
     * set value from double[] using normalized index
     */
    public static void objectArraySet(Object[] a, int i, Object v) {
        try {
            a[i]=v;
        } catch (Throwable t) {
            a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)]=v;
        }
    }
}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy BytecodeInterface8.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.