@@ -107,12 +107,13 @@ private String methods() {
107107 Set <Modifier > modifiers = methodElement .getModifiers ();
108108 if (modifiers .contains (Modifier .PRIVATE )
109109 || modifiers .contains (Modifier .STATIC )
110- || modifiers .contains (Modifier .PROTECTED )
111110 || methodElement .getEnclosingElement ().getSimpleName ().contentEquals ("Object" )) continue ;
112111 // Access modifiers
113112 sb .append (" @Override\n " );
114113 if (modifiers .contains (Modifier .PUBLIC )) {
115114 sb .append (" public " );
115+ } else if (modifiers .contains (Modifier .PROTECTED )) {
116+ sb .append (" protected " );
116117 } else {
117118 sb .append (" " );
118119 }
@@ -162,19 +163,24 @@ private String methods() {
162163 }
163164
164165 sb .append (" {\n " );
165- if (!"void" .equals (returnType .full ())) {
166- sb .append ("return " );
167- }
166+ if (modifiers .contains (Modifier .PROTECTED )) {
167+ sb .append ("// @Lazy proxy does not support protected methods, instead use @Lazy(useProxy = false)" );
168+ sb .append ("\n throw new UnsupportedOperationException();\n " );
169+ } else {
170+ if (!"void" .equals (returnType .full ())) {
171+ sb .append ("return " );
172+ }
168173
169- sb .append ("onceProvider.get()." ).append (methodName );
170- sb .append ("(" );
171- for (int i = 0 ; i < parameters .size (); i ++) {
172- sb .append (parameters .get (i ).getSimpleName ().toString ());
173- if (i < parameters .size () - 1 ) {
174- sb .append (", " );
174+ sb .append ("onceProvider.get()." ).append (methodName );
175+ sb .append ("(" );
176+ for (int i = 0 ; i < parameters .size (); i ++) {
177+ sb .append (parameters .get (i ).getSimpleName ().toString ());
178+ if (i < parameters .size () - 1 ) {
179+ sb .append (", " );
180+ }
175181 }
182+ sb .append (");\n " );
176183 }
177- sb .append (");\n " );
178184 sb .append (" }\n \n " );
179185 }
180186 return sb .toString ();
0 commit comments