@@ -210,7 +210,12 @@ protected void enterTypeDeclaration(ParserRuleContext ctx, int access) {
210210 superQualifiedTypeName = resolveInternalTypeName (superType .classOrInterfaceType ().Identifier ());
211211 }
212212
213- access += getTypeDeclarationContextAccessFlag (ctx .getParent ());
213+ ParserRuleContext parent = ctx .getParent ();
214+
215+ if (parent instanceof JavaParser .TypeDeclarationContext )
216+ access += getTypeDeclarationContextAccessFlag (parent );
217+ else if (parent instanceof JavaParser .MemberDeclarationContext )
218+ access += getMemberDeclarationContextAccessFlag (parent .getParent ());
214219
215220 if (currentType == null ) {
216221 String internalTypeName = packageName .isEmpty () ? name : packageName + "/" + name ;
@@ -317,8 +322,6 @@ public void enterMethodDeclaration(
317322
318323 public void enterConstructorDeclaration (JavaParser .ConstructorDeclarationContext ctx ) {
319324 int access = getClassBodyDeclarationAccessFlag (ctx .getParent ().getParent ());
320- TerminalNode identifier = ctx .Identifier ();
321- String name = identifier .getText ();
322325 String paramDescriptors = createParamDescriptors (ctx .formalParameters ().formalParameterList ());
323326 String descriptor = paramDescriptors + "V" ;
324327
@@ -344,27 +347,44 @@ protected String createParamDescriptors(JavaParser.FormalParameterListContext fo
344347 protected int getTypeDeclarationContextAccessFlag (ParserRuleContext ctx ) {
345348 int access = 0 ;
346349
347- for (JavaParser .ClassOrInterfaceModifierContext modifierContext : ctx .getRuleContexts (JavaParser .ClassOrInterfaceModifierContext .class )) {
348- access += getAccessFlag (modifierContext );
350+ for (JavaParser .ClassOrInterfaceModifierContext coiModifierContext : ctx .getRuleContexts (JavaParser .ClassOrInterfaceModifierContext .class )) {
351+ access += getAccessFlag (coiModifierContext );
349352 }
350353
351354 return access ;
352355 }
353356
354- protected int getClassBodyDeclarationAccessFlag (ParserRuleContext ctx ) {
357+ protected int getMemberDeclarationContextAccessFlag (ParserRuleContext ctx ) {
355358 int access = 0 ;
356359
357360 for (JavaParser .ModifierContext modifierContext : ctx .getRuleContexts (JavaParser .ModifierContext .class )) {
358- JavaParser .ClassOrInterfaceModifierContext coimc = modifierContext .classOrInterfaceModifier ();
359-
360- if (coimc != null ) {
361- access += getAccessFlag (coimc );
361+ JavaParser .ClassOrInterfaceModifierContext coiModifierContext = modifierContext .classOrInterfaceModifier ();
362+ if (coiModifierContext != null ) {
363+ access += getAccessFlag (coiModifierContext );
362364 }
363365 }
364366
365367 return access ;
366368 }
367369
370+ protected int getClassBodyDeclarationAccessFlag (ParserRuleContext ctx ) {
371+ if ((currentType .access & JavaType .FLAG_INTERFACE ) == 0 ) {
372+ int access = 0 ;
373+
374+ for (JavaParser .ModifierContext modifierContext : ctx .getRuleContexts (JavaParser .ModifierContext .class )) {
375+ JavaParser .ClassOrInterfaceModifierContext coimc = modifierContext .classOrInterfaceModifier ();
376+
377+ if (coimc != null ) {
378+ access += getAccessFlag (coimc );
379+ }
380+ }
381+
382+ return access ;
383+ } else {
384+ return JavaType .FLAG_PUBLIC ;
385+ }
386+ }
387+
368388 protected int getAccessFlag (JavaParser .ClassOrInterfaceModifierContext ctx ) {
369389 if (ctx .getChildCount () == 1 ) {
370390 ParseTree first = ctx .getChild (0 );
0 commit comments