001// ASM: a very small and fast Java bytecode manipulation framework 002// Copyright (c) 2000-2011 INRIA, France Telecom 003// All rights reserved. 004// 005// Redistribution and use in source and binary forms, with or without 006// modification, are permitted provided that the following conditions 007// are met: 008// 1. Redistributions of source code must retain the above copyright 009// notice, this list of conditions and the following disclaimer. 010// 2. Redistributions in binary form must reproduce the above copyright 011// notice, this list of conditions and the following disclaimer in the 012// documentation and/or other materials provided with the distribution. 013// 3. Neither the name of the copyright holders nor the names of its 014// contributors may be used to endorse or promote products derived from 015// this software without specific prior written permission. 016// 017// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 018// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 019// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 020// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 021// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 022// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 023// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 024// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 025// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 026// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 027// THE POSSIBILITY OF SUCH DAMAGE. 028 029package io.ebean.enhance.asm.commons; 030 031import io.ebean.enhance.asm.*; 032 033/** 034 * A ModuleResolution attribute. This attribute is specific to the OpenJDK and may change in the 035 * future. 036 * 037 * @author Remi Forax 038 */ 039public final class ModuleResolutionAttribute extends Attribute { 040 /** 041 * The resolution state of a module meaning that the module is not available from the class-path 042 * by default. 043 */ 044 public static final int RESOLUTION_DO_NOT_RESOLVE_BY_DEFAULT = 1; 045 046 /** The resolution state of a module meaning the module is marked as deprecated. */ 047 public static final int RESOLUTION_WARN_DEPRECATED = 2; 048 049 /** 050 * The resolution state of a module meaning the module is marked as deprecated and will be removed 051 * in a future release. 052 */ 053 public static final int RESOLUTION_WARN_DEPRECATED_FOR_REMOVAL = 4; 054 055 /** 056 * The resolution state of a module meaning the module is not yet standardized, so in incubating 057 * mode. 058 */ 059 public static final int RESOLUTION_WARN_INCUBATING = 8; 060 061 /** 062 * The resolution state of the module. Must be one of {@link #RESOLUTION_WARN_DEPRECATED}, {@link 063 * #RESOLUTION_WARN_DEPRECATED_FOR_REMOVAL}, and {@link #RESOLUTION_WARN_INCUBATING}. 064 */ 065 public int resolution; 066 067 /** 068 * Constructs a new {@link ModuleResolutionAttribute}. 069 * 070 * @param resolution the resolution state of the module. Must be one of {@link 071 * #RESOLUTION_WARN_DEPRECATED}, {@link #RESOLUTION_WARN_DEPRECATED_FOR_REMOVAL}, and {@link 072 * #RESOLUTION_WARN_INCUBATING}. 073 */ 074 public ModuleResolutionAttribute(final int resolution) { 075 super("ModuleResolution"); 076 this.resolution = resolution; 077 } 078 079 /** 080 * Constructs an empty {@link ModuleResolutionAttribute}. This object can be passed as a prototype 081 * to the {@link ClassReader#accept(ClassVisitor, Attribute[], int)} method. 082 */ 083 public ModuleResolutionAttribute() { 084 this(0); 085 } 086 087 @Override 088 protected Attribute read( 089 final ClassReader classReader, 090 final int offset, 091 final int length, 092 final char[] charBuffer, 093 final int codeOffset, 094 final Label[] labels) { 095 return new ModuleResolutionAttribute(classReader.readUnsignedShort(offset)); 096 } 097 098 @Override 099 protected ByteVector write( 100 final ClassWriter classWriter, 101 final byte[] code, 102 final int codeLength, 103 final int maxStack, 104 final int maxLocals) { 105 ByteVector byteVector = new ByteVector(); 106 byteVector.putShort(resolution); 107 return byteVector; 108 } 109}