Parse a type signature.

@param parser
The parser
@param definingClass
The class containing the type descriptor.
@return The parsed type descriptor or type signature.
@throws ParseException
If the type signature could not be parsed.
769112
static TypeSignature parse(final Parser parser, final String definingClass) throws ParseException {
        final ReferenceTypeSignature referenceTypeSignature = ReferenceTypeSignature
                .parseReferenceTypeSignature(parser, definingClass);
        if (referenceTypeSignature != null) {
            return referenceTypeSignature;
        }
        final BaseTypeSignature baseTypeSignature = BaseTypeSignature.parse(parser);
        if (baseTypeSignature != null) {
            return baseTypeSignature;
        }
        return null;
    }
791445
private TypeSignature getTypeSignature() {
        if (typeSignature == null) {
            try {
                // There can't be any type variables to resolve in either ClassRefTypeSignature or
                // BaseTypeSignature, so just set definingClassName to null
                typeSignature = TypeSignature.parse(typeDescriptorStr, /* definingClassName = */ null);
                typeSignature.setScanResult(scanResult);
            } catch (final ParseException e) {
                throw new IllegalArgumentException(e);
            }
        }
        return typeSignature;
    }
1339893
public static Object loadGenInstance(Class<?> cls) throws ParserException
    {
        try
        {
            Class<?> parserClass;
            try
            {
                parserClass = loadGenClass(cls);
            }
            catch (ClassNotFoundException ex)
            {
                return null;
            }
            return parserClass.newInstance();
        }
        catch (InstantiationException | IllegalAccessException ex)
        {
            throw new ParserException(ex);
        }
    }
1193428
public final void classOrInterfaceDeclaration() throws RecognitionException {
		int classOrInterfaceDeclaration_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 5) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:290:5: ( ( modifier )* ( classDeclaration | interfaceDeclaration ) )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:290:7: ( modifier )* ( classDeclaration | interfaceDeclaration )
			{
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:290:7: ( modifier )*
			loop9:
			while (true) {
				int alt9=2;
				int LA9_0 = input.LA(1);
				if ( (LA9_0==58) ) {
					int LA9_4 = input.LA(2);
					if ( (LA9_4==Identifier) ) {
						alt9=1;
					}

				}
				else if ( (LA9_0==63||LA9_0==83||LA9_0==96||(LA9_0 >= 100 && LA9_0 <= 102)||(LA9_0 >= 106 && LA9_0 <= 107)||LA9_0==110||LA9_0==114||LA9_0==119) ) {
					alt9=1;
				}

				switch (alt9) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:290:7: modifier
					{
					pushFollow(FOLLOW_modifier_in_classOrInterfaceDeclaration218);
					modifier();
					state._fsp--;
					if (state.failed) return;
					}
					break;

				default :
					break loop9;
				}
			}

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:290:17: ( classDeclaration | interfaceDeclaration )
			int alt10=2;
			int LA10_0 = input.LA(1);
			if ( (LA10_0==ENUM||LA10_0==72) ) {
				alt10=1;
			}
			else if ( (LA10_0==58||LA10_0==93) ) {
				alt10=2;
			}

			else {
				if (state.backtracking>0) {state.failed=true; return;}
				NoViableAltException nvae =
					new NoViableAltException("", 10, 0, input);
				throw nvae;
			}

			switch (alt10) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:290:18: classDeclaration
					{
					pushFollow(FOLLOW_classDeclaration_in_classOrInterfaceDeclaration222);
					classDeclaration();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:290:37: interfaceDeclaration
					{
					pushFollow(FOLLOW_interfaceDeclaration_in_classOrInterfaceDeclaration226);
					interfaceDeclaration();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}

			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 5, classOrInterfaceDeclaration_StartIndex); }

		}
	}
398852
final public void Identifier() throws ParseException {
                                 /*@bgen(jjtree) Identifier */
                                  AstIdentifier jjtn000 = new AstIdentifier(JJTIDENTIFIER);
                                  boolean jjtc000 = true;
                                  jjtree.openNodeScope(jjtn000);Token t = null;
    try {
      t = jj_consume_token(IDENTIFIER);
                     jjtree.closeNodeScope(jjtn000, true);
                     jjtc000 = false;
                     jjtn000.setImage(t.image);
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
      }
    }
  }
780478
@FFDCIgnore(JAXBException.class)
    public static Object parseRaDeploymentDescriptor(com.ibm.wsspi.adaptable.module.Entry ddEntry) throws JAXBException, SAXException, ParserConfigurationException, UnableToAdaptException {
        Object connector = null;
        try {
            connector = parseResourceAdapterXml(ddEntry.adapt(InputStream.class), ddEntry.getName(), false);
        } catch (JAXBException jax) {
            if (isVersion10ResourceAdapter(ddEntry.adapt(InputStream.class))) {
                if (ra10Context == null) {
                    ra10Context = JAXBContext.newInstance(Ra10Connector.class);
                }
                connector = parseResourceAdapterXml(ddEntry.adapt(InputStream.class), ddEntry.getName(), true);
            } else {
                throw jax;
            }
        }
        return connector;
    }
248932
public final void mBEGINTYPEPARAM() throws RecognitionException {
        try {
            int _type = BEGINTYPEPARAM;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // org/javaruntype/type/parser/Type.g:32:16: ( '<' )
            // org/javaruntype/type/parser/Type.g:32:18: '<'
            {
            match('<'); 

            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
844784
public final void normalClassDeclaration() throws RecognitionException {
		int normalClassDeclaration_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 7) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:299:5: ( 'class' Identifier ( typeParameters )? ( 'extends' type )? ( 'implements' typeList )? classBody )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:299:7: 'class' Identifier ( typeParameters )? ( 'extends' type )? ( 'implements' typeList )? classBody
			{
			match(input,72,FOLLOW_72_in_normalClassDeclaration271); if (state.failed) return;
			match(input,Identifier,FOLLOW_Identifier_in_normalClassDeclaration273); if (state.failed) return;
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:299:26: ( typeParameters )?
			int alt12=2;
			int LA12_0 = input.LA(1);
			if ( (LA12_0==53) ) {
				alt12=1;
			}
			switch (alt12) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:299:27: typeParameters
					{
					pushFollow(FOLLOW_typeParameters_in_normalClassDeclaration276);
					typeParameters();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:300:9: ( 'extends' type )?
			int alt13=2;
			int LA13_0 = input.LA(1);
			if ( (LA13_0==81) ) {
				alt13=1;
			}
			switch (alt13) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:300:10: 'extends' type
					{
					match(input,81,FOLLOW_81_in_normalClassDeclaration289); if (state.failed) return;
					pushFollow(FOLLOW_type_in_normalClassDeclaration291);
					type();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:301:9: ( 'implements' typeList )?
			int alt14=2;
			int LA14_0 = input.LA(1);
			if ( (LA14_0==88) ) {
				alt14=1;
			}
			switch (alt14) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:301:10: 'implements' typeList
					{
					match(input,88,FOLLOW_88_in_normalClassDeclaration304); if (state.failed) return;
					pushFollow(FOLLOW_typeList_in_normalClassDeclaration306);
					typeList();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}

			pushFollow(FOLLOW_classBody_in_normalClassDeclaration318);
			classBody();
			state._fsp--;
			if (state.failed) return;
			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 7, normalClassDeclaration_StartIndex); }

		}
	}
450542
Class<?> defineClass(String name, byte[] bytes) throws ClassFormatError {
		try {
			// Attempt to load the access class in the same loader, which makes
			// protected and default access members accessible.
			Method method = ClassLoader.class.getDeclaredMethod("defineClass", DEF_CLASS_SIG);
			method.setAccessible(true);
			return (Class<?>) method.invoke(getParent(), new Object[] { name, bytes, Integer.valueOf(0), Integer.valueOf(bytes.length) });
		} catch (Exception ignored) {
		}
		return defineClass(name, bytes, 0, bytes.length);
	}
628509
protected void setDescriptor(Text line) throws ParseException {
        line.trim();
        try {
            //split using equal sign
            Iterator<Text> it = line.split('=').iterator();

            //skip first token (m)
            Text t = it.next();

            //select second token (media_type port profile formats)
            t = it.next();

            //split using white spaces
            it = t.split(' ').iterator();

            //media type
            mediaType = it.next();
            mediaType.trim();

            //port
            t = it.next();
            t.trim();
            port = t.toInteger();

            //profile
            profile = it.next();
            profile.trim();

            //formats
            while (it.hasNext()) {
                t = it.next();
                t.trim();

                RTPFormat fmt = AVProfile.getFormat(t.toInteger(),mediaType);
                if (fmt != null && !formats.contains(fmt.getFormat())) {
                    formats.add(fmt.clone());
                }
            }
        } catch (Exception e) {
            throw new ParseException("Could not parse media descriptor", 0);
        }
    }
1127863
static BaseTypeSignature parse(final Parser parser) {
        switch (parser.peek()) {
        case 'B':
            parser.next();
            return new BaseTypeSignature("byte");
        case 'C':
            parser.next();
            return new BaseTypeSignature("char");
        case 'D':
            parser.next();
            return new BaseTypeSignature("double");
        case 'F':
            parser.next();
            return new BaseTypeSignature("float");
        case 'I':
            parser.next();
            return new BaseTypeSignature("int");
        case 'J':
            parser.next();
            return new BaseTypeSignature("long");
        case 'S':
            parser.next();
            return new BaseTypeSignature("short");
        case 'Z':
            parser.next();
            return new BaseTypeSignature("boolean");
        case 'V':
            parser.next();
            return new BaseTypeSignature("void");
        default:
            return null;
        }
    }
246246
private static int checkClassTypeSignature(final String signature, int pos) {
        // ClassTypeSignature:
        // L Identifier ( / Identifier )* TypeArguments? ( . Identifier
        // TypeArguments? )* ;

        pos = checkChar('L', signature, pos);
        pos = checkIdentifier(signature, pos);
        while (getChar(signature, pos) == '/') {
            pos = checkIdentifier(signature, pos + 1);
        }
        if (getChar(signature, pos) == '<') {
            pos = checkTypeArguments(signature, pos);
        }
        while (getChar(signature, pos) == '.') {
            pos = checkIdentifier(signature, pos + 1);
            if (getChar(signature, pos) == '<') {
                pos = checkTypeArguments(signature, pos);
            }
        }
        return checkChar(';', signature, pos);
    }
889058
public final Parser<T> followedBy(Parser<?> parser) {
    return Parsers.sequence(this, parser, InternalFunctors.<T, Object>firstOfTwo());
  }
474397
public final void classDeclaration() throws RecognitionException {
		int classDeclaration_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 6) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:294:5: ( normalClassDeclaration | enumDeclaration )
			int alt11=2;
			int LA11_0 = input.LA(1);
			if ( (LA11_0==72) ) {
				alt11=1;
			}
			else if ( (LA11_0==ENUM) ) {
				alt11=2;
			}

			else {
				if (state.backtracking>0) {state.failed=true; return;}
				NoViableAltException nvae =
					new NoViableAltException("", 11, 0, input);
				throw nvae;
			}

			switch (alt11) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:294:7: normalClassDeclaration
					{
					pushFollow(FOLLOW_normalClassDeclaration_in_classDeclaration244);
					normalClassDeclaration();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:295:9: enumDeclaration
					{
					pushFollow(FOLLOW_enumDeclaration_in_classDeclaration254);
					enumDeclaration();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}
		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 6, classDeclaration_StartIndex); }

		}
	}
1152568
@Override
    public ClassNode visitTypeDeclaration(TypeDeclarationContext ctx) {
        if (asBoolean(ctx.classDeclaration())) { // e.g. class A {}
            ctx.classDeclaration().putNodeMetaData(TYPE_DECLARATION_MODIFIERS, this.visitClassOrInterfaceModifiersOpt(ctx.classOrInterfaceModifiersOpt()));
            return configureAST(this.visitClassDeclaration(ctx.classDeclaration()), ctx);
        }

        throw createParsingFailedException("Unsupported type declaration: " + ctx.getText(), ctx);
    }
4205
public ClassTypeSignature getTypeSignature() {
        if (typeSignatureStr == null) {
            return null;
        }
        if (typeSignature == null) {
            try {
                typeSignature = ClassTypeSignature.parse(typeSignatureStr, this);
                typeSignature.setScanResult(scanResult);
            } catch (final ParseException e) {
                throw new IllegalArgumentException(e);
            }
        }
        return typeSignature;
    }
215545
public TypeSignature getTypeDescriptor() {
        if (typeDescriptorStr == null) {
            return null;
        }
        if (typeDescriptor == null) {
            try {
                typeDescriptor = TypeSignature.parse(typeDescriptorStr, declaringClassName);
                typeDescriptor.setScanResult(scanResult);
            } catch (final ParseException e) {
                throw new IllegalArgumentException(e);
            }
        }
        return typeDescriptor;
    }