Outer Class can have how many inner class(es) [on hold]Get full class name of an inner class...
Why didn’t Doctor Strange stay in the original winning timeline?
Does Git delete empty folders?
What can I do to keep a threaded bolt from falling out of its slot?
How to compare two different formulations of a problem?
What professions would a medieval village with a population of 100 need?
Have only girls been born for a long time in this village?
What happens when I copy a legendary creature with Rite of Replication?
Potential new partner angry about first collaboration - how to answer email to close up this encounter in a graceful manner
How to specify and fit a hybrid machine learning - linear model
How would one country purchase another?
Is "stainless" a bulk or a surface property of stainless steel?
What is the improvement of the "legally binding commitment" proposed by Boris Johnson over the existing "backstop"?
Is it safe to remove the bottom chords of a series of garage roof trusses?
How to avoid using System.String with Rfc2898DeriveBytes in C#
How to get the pandadocs from an opportunity?
What is "Wayfinder's Guide to Eberron"?
What's /System/Volumes/Data?
Why are delta bots so finicky?
Why would the US President need briefings on UFOs?
Why we don't have vaccination against all diseases which are caused by microbes?
Can my boyfriend, who lives in the UK and has a Polish passport, visit me in the USA?
Was 'help' pronounced starting with a vowel sound?
Was Tuvok bluffing when he said that Voyager's transporters rendered the Kazon weapons useless?
Does Swashbuckler's Fancy Footwork apply if the attack was made with Booming Blade?
Outer Class can have how many inner class(es) [on hold]
Get full class name of an inner class instance?Accessing an Outer Class's Members from an Inner ClassHow to access outer class instance variables from inner class in controller?How to include inner class/wrapper class in test method?Inner classes can access outer class private variablesInner class using container classPossible to declare static constants in an inner class?Purpose of an inner classProblem using Protected modifier to expose method to inner class
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
In Apex, how many inner classes can an outer class have?
apex
New contributor
put on hold as off-topic by Sebastian Kessel, Raul, salesforce-sas, glls, Vijay Ganji yesterday
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Sebastian Kessel, Raul, salesforce-sas, glls, Vijay Ganji
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
In Apex, how many inner classes can an outer class have?
apex
New contributor
put on hold as off-topic by Sebastian Kessel, Raul, salesforce-sas, glls, Vijay Ganji yesterday
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Sebastian Kessel, Raul, salesforce-sas, glls, Vijay Ganji
If this question can be reworded to fit the rules in the help center, please edit the question.
1
Welcome to SFSE! Please take the tour and read How to Ask. I don't think there's any practical limit here, but I doubt there's documentation to back that up. This question, though, gives me an X-Y Problem vibe. I get the feeling that you either have a class with a bunch of inner classes and are running into an issue, or are trying to solve a problem and think that using a bunch of inner classes is the answer. Either way, the best way to get help from this community is to provide us with lots of details. What is your problem? How are you trying to solve it?
– Derek F
Aug 17 at 23:05
If you're getting an error message, providing the full error message, verbatim, really helps. The more relevant detail you can give us, the better we'll be able to understand your situation. Ultimately, that should end up getting you more useful and accurate answers.
– Derek F
Aug 17 at 23:09
2
And, for what it's worth, I've personally had somewhere between 12 - 36 inner classes contained in a single outer class (mostly just to help deserialize payloads from an external system). Haven't really counted the exact number.
– Derek F
Aug 17 at 23:14
add a comment |
In Apex, how many inner classes can an outer class have?
apex
New contributor
In Apex, how many inner classes can an outer class have?
apex
apex
New contributor
New contributor
edited 2 days ago
Adrian Larson♦
116k19 gold badges136 silver badges275 bronze badges
116k19 gold badges136 silver badges275 bronze badges
New contributor
asked Aug 17 at 22:55
FaizFaiz
61 bronze badge
61 bronze badge
New contributor
New contributor
put on hold as off-topic by Sebastian Kessel, Raul, salesforce-sas, glls, Vijay Ganji yesterday
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Sebastian Kessel, Raul, salesforce-sas, glls, Vijay Ganji
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by Sebastian Kessel, Raul, salesforce-sas, glls, Vijay Ganji yesterday
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Sebastian Kessel, Raul, salesforce-sas, glls, Vijay Ganji
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by Sebastian Kessel, Raul, salesforce-sas, glls, Vijay Ganji yesterday
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Sebastian Kessel, Raul, salesforce-sas, glls, Vijay Ganji
If this question can be reworded to fit the rules in the help center, please edit the question.
1
Welcome to SFSE! Please take the tour and read How to Ask. I don't think there's any practical limit here, but I doubt there's documentation to back that up. This question, though, gives me an X-Y Problem vibe. I get the feeling that you either have a class with a bunch of inner classes and are running into an issue, or are trying to solve a problem and think that using a bunch of inner classes is the answer. Either way, the best way to get help from this community is to provide us with lots of details. What is your problem? How are you trying to solve it?
– Derek F
Aug 17 at 23:05
If you're getting an error message, providing the full error message, verbatim, really helps. The more relevant detail you can give us, the better we'll be able to understand your situation. Ultimately, that should end up getting you more useful and accurate answers.
– Derek F
Aug 17 at 23:09
2
And, for what it's worth, I've personally had somewhere between 12 - 36 inner classes contained in a single outer class (mostly just to help deserialize payloads from an external system). Haven't really counted the exact number.
– Derek F
Aug 17 at 23:14
add a comment |
1
Welcome to SFSE! Please take the tour and read How to Ask. I don't think there's any practical limit here, but I doubt there's documentation to back that up. This question, though, gives me an X-Y Problem vibe. I get the feeling that you either have a class with a bunch of inner classes and are running into an issue, or are trying to solve a problem and think that using a bunch of inner classes is the answer. Either way, the best way to get help from this community is to provide us with lots of details. What is your problem? How are you trying to solve it?
– Derek F
Aug 17 at 23:05
If you're getting an error message, providing the full error message, verbatim, really helps. The more relevant detail you can give us, the better we'll be able to understand your situation. Ultimately, that should end up getting you more useful and accurate answers.
– Derek F
Aug 17 at 23:09
2
And, for what it's worth, I've personally had somewhere between 12 - 36 inner classes contained in a single outer class (mostly just to help deserialize payloads from an external system). Haven't really counted the exact number.
– Derek F
Aug 17 at 23:14
1
1
Welcome to SFSE! Please take the tour and read How to Ask. I don't think there's any practical limit here, but I doubt there's documentation to back that up. This question, though, gives me an X-Y Problem vibe. I get the feeling that you either have a class with a bunch of inner classes and are running into an issue, or are trying to solve a problem and think that using a bunch of inner classes is the answer. Either way, the best way to get help from this community is to provide us with lots of details. What is your problem? How are you trying to solve it?
– Derek F
Aug 17 at 23:05
Welcome to SFSE! Please take the tour and read How to Ask. I don't think there's any practical limit here, but I doubt there's documentation to back that up. This question, though, gives me an X-Y Problem vibe. I get the feeling that you either have a class with a bunch of inner classes and are running into an issue, or are trying to solve a problem and think that using a bunch of inner classes is the answer. Either way, the best way to get help from this community is to provide us with lots of details. What is your problem? How are you trying to solve it?
– Derek F
Aug 17 at 23:05
If you're getting an error message, providing the full error message, verbatim, really helps. The more relevant detail you can give us, the better we'll be able to understand your situation. Ultimately, that should end up getting you more useful and accurate answers.
– Derek F
Aug 17 at 23:09
If you're getting an error message, providing the full error message, verbatim, really helps. The more relevant detail you can give us, the better we'll be able to understand your situation. Ultimately, that should end up getting you more useful and accurate answers.
– Derek F
Aug 17 at 23:09
2
2
And, for what it's worth, I've personally had somewhere between 12 - 36 inner classes contained in a single outer class (mostly just to help deserialize payloads from an external system). Haven't really counted the exact number.
– Derek F
Aug 17 at 23:14
And, for what it's worth, I've personally had somewhere between 12 - 36 inner classes contained in a single outer class (mostly just to help deserialize payloads from an external system). Haven't really counted the exact number.
– Derek F
Aug 17 at 23:14
add a comment |
2 Answers
2
active
oldest
votes
In the name of science, I attempted to save a class with programmatically generated inner classes that looked like the following:
public with sharing class Demo
{
public class Inner0 { }
public class Inner1 { }
public class Inner2 { }
public class Inner3 { }
// ...
}
I kept expanding this pattern until I ran into an error. Adding 1000 at a time, it worked until I hit InnerClass7000
, at which point I hit a generic compile fail:
An unexpected error occurred
I walked it back until I found the exact maximum number of classes where I would not hit this error, and it is 6663. I was kind of hoping it would be 6666, but alas.
Compiles:
public with sharing class Demo
{
// ...
public class Inner6661 { }
public class Inner6662 { }
public class Inner6663 { }
}
Does not compile:
public with sharing class Demo
{
// ...
public class Inner6662 { }
public class Inner6663 { }
public class Inner6664 { }
}
If you are inquiring about how deeply nested inner classes can be, it is capped at one level.
public class Outer
{
public class Inner
{
public class TooDeep
{
// not allowed
}
}
}
See also, Apex Class Definition (emphasis mine):
In Apex, you can define top-level classes (also called outer classes) as well as inner classes, that is, a class defined within another class. You can only have inner classes one level deep.
The unexpected error was interesting. I was guessing you could go much higher... but alas.
– sfdcfox
2 days ago
Yeah if I had to guess, I too would have expected a higher number.
– Adrian Larson♦
2 days ago
add a comment |
The language spec doesn't say, so in theory, you could have 111,535 inner classes before you got a "class too large" error for exceeding 1,000,000 characters. It appears that a compiler error limits you to an actual value of 6,663. In the "real world", having more than 5-10 classes should be a sign that you should probably refactor and/or extract some classes in other other classes or top-level classes. The exception to this rule of thumb would be automatically generated code, such as WSDL2Apex, or JSON2Apex.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In the name of science, I attempted to save a class with programmatically generated inner classes that looked like the following:
public with sharing class Demo
{
public class Inner0 { }
public class Inner1 { }
public class Inner2 { }
public class Inner3 { }
// ...
}
I kept expanding this pattern until I ran into an error. Adding 1000 at a time, it worked until I hit InnerClass7000
, at which point I hit a generic compile fail:
An unexpected error occurred
I walked it back until I found the exact maximum number of classes where I would not hit this error, and it is 6663. I was kind of hoping it would be 6666, but alas.
Compiles:
public with sharing class Demo
{
// ...
public class Inner6661 { }
public class Inner6662 { }
public class Inner6663 { }
}
Does not compile:
public with sharing class Demo
{
// ...
public class Inner6662 { }
public class Inner6663 { }
public class Inner6664 { }
}
If you are inquiring about how deeply nested inner classes can be, it is capped at one level.
public class Outer
{
public class Inner
{
public class TooDeep
{
// not allowed
}
}
}
See also, Apex Class Definition (emphasis mine):
In Apex, you can define top-level classes (also called outer classes) as well as inner classes, that is, a class defined within another class. You can only have inner classes one level deep.
The unexpected error was interesting. I was guessing you could go much higher... but alas.
– sfdcfox
2 days ago
Yeah if I had to guess, I too would have expected a higher number.
– Adrian Larson♦
2 days ago
add a comment |
In the name of science, I attempted to save a class with programmatically generated inner classes that looked like the following:
public with sharing class Demo
{
public class Inner0 { }
public class Inner1 { }
public class Inner2 { }
public class Inner3 { }
// ...
}
I kept expanding this pattern until I ran into an error. Adding 1000 at a time, it worked until I hit InnerClass7000
, at which point I hit a generic compile fail:
An unexpected error occurred
I walked it back until I found the exact maximum number of classes where I would not hit this error, and it is 6663. I was kind of hoping it would be 6666, but alas.
Compiles:
public with sharing class Demo
{
// ...
public class Inner6661 { }
public class Inner6662 { }
public class Inner6663 { }
}
Does not compile:
public with sharing class Demo
{
// ...
public class Inner6662 { }
public class Inner6663 { }
public class Inner6664 { }
}
If you are inquiring about how deeply nested inner classes can be, it is capped at one level.
public class Outer
{
public class Inner
{
public class TooDeep
{
// not allowed
}
}
}
See also, Apex Class Definition (emphasis mine):
In Apex, you can define top-level classes (also called outer classes) as well as inner classes, that is, a class defined within another class. You can only have inner classes one level deep.
The unexpected error was interesting. I was guessing you could go much higher... but alas.
– sfdcfox
2 days ago
Yeah if I had to guess, I too would have expected a higher number.
– Adrian Larson♦
2 days ago
add a comment |
In the name of science, I attempted to save a class with programmatically generated inner classes that looked like the following:
public with sharing class Demo
{
public class Inner0 { }
public class Inner1 { }
public class Inner2 { }
public class Inner3 { }
// ...
}
I kept expanding this pattern until I ran into an error. Adding 1000 at a time, it worked until I hit InnerClass7000
, at which point I hit a generic compile fail:
An unexpected error occurred
I walked it back until I found the exact maximum number of classes where I would not hit this error, and it is 6663. I was kind of hoping it would be 6666, but alas.
Compiles:
public with sharing class Demo
{
// ...
public class Inner6661 { }
public class Inner6662 { }
public class Inner6663 { }
}
Does not compile:
public with sharing class Demo
{
// ...
public class Inner6662 { }
public class Inner6663 { }
public class Inner6664 { }
}
If you are inquiring about how deeply nested inner classes can be, it is capped at one level.
public class Outer
{
public class Inner
{
public class TooDeep
{
// not allowed
}
}
}
See also, Apex Class Definition (emphasis mine):
In Apex, you can define top-level classes (also called outer classes) as well as inner classes, that is, a class defined within another class. You can only have inner classes one level deep.
In the name of science, I attempted to save a class with programmatically generated inner classes that looked like the following:
public with sharing class Demo
{
public class Inner0 { }
public class Inner1 { }
public class Inner2 { }
public class Inner3 { }
// ...
}
I kept expanding this pattern until I ran into an error. Adding 1000 at a time, it worked until I hit InnerClass7000
, at which point I hit a generic compile fail:
An unexpected error occurred
I walked it back until I found the exact maximum number of classes where I would not hit this error, and it is 6663. I was kind of hoping it would be 6666, but alas.
Compiles:
public with sharing class Demo
{
// ...
public class Inner6661 { }
public class Inner6662 { }
public class Inner6663 { }
}
Does not compile:
public with sharing class Demo
{
// ...
public class Inner6662 { }
public class Inner6663 { }
public class Inner6664 { }
}
If you are inquiring about how deeply nested inner classes can be, it is capped at one level.
public class Outer
{
public class Inner
{
public class TooDeep
{
// not allowed
}
}
}
See also, Apex Class Definition (emphasis mine):
In Apex, you can define top-level classes (also called outer classes) as well as inner classes, that is, a class defined within another class. You can only have inner classes one level deep.
edited 2 days ago
answered 2 days ago
Adrian Larson♦Adrian Larson
116k19 gold badges136 silver badges275 bronze badges
116k19 gold badges136 silver badges275 bronze badges
The unexpected error was interesting. I was guessing you could go much higher... but alas.
– sfdcfox
2 days ago
Yeah if I had to guess, I too would have expected a higher number.
– Adrian Larson♦
2 days ago
add a comment |
The unexpected error was interesting. I was guessing you could go much higher... but alas.
– sfdcfox
2 days ago
Yeah if I had to guess, I too would have expected a higher number.
– Adrian Larson♦
2 days ago
The unexpected error was interesting. I was guessing you could go much higher... but alas.
– sfdcfox
2 days ago
The unexpected error was interesting. I was guessing you could go much higher... but alas.
– sfdcfox
2 days ago
Yeah if I had to guess, I too would have expected a higher number.
– Adrian Larson♦
2 days ago
Yeah if I had to guess, I too would have expected a higher number.
– Adrian Larson♦
2 days ago
add a comment |
The language spec doesn't say, so in theory, you could have 111,535 inner classes before you got a "class too large" error for exceeding 1,000,000 characters. It appears that a compiler error limits you to an actual value of 6,663. In the "real world", having more than 5-10 classes should be a sign that you should probably refactor and/or extract some classes in other other classes or top-level classes. The exception to this rule of thumb would be automatically generated code, such as WSDL2Apex, or JSON2Apex.
add a comment |
The language spec doesn't say, so in theory, you could have 111,535 inner classes before you got a "class too large" error for exceeding 1,000,000 characters. It appears that a compiler error limits you to an actual value of 6,663. In the "real world", having more than 5-10 classes should be a sign that you should probably refactor and/or extract some classes in other other classes or top-level classes. The exception to this rule of thumb would be automatically generated code, such as WSDL2Apex, or JSON2Apex.
add a comment |
The language spec doesn't say, so in theory, you could have 111,535 inner classes before you got a "class too large" error for exceeding 1,000,000 characters. It appears that a compiler error limits you to an actual value of 6,663. In the "real world", having more than 5-10 classes should be a sign that you should probably refactor and/or extract some classes in other other classes or top-level classes. The exception to this rule of thumb would be automatically generated code, such as WSDL2Apex, or JSON2Apex.
The language spec doesn't say, so in theory, you could have 111,535 inner classes before you got a "class too large" error for exceeding 1,000,000 characters. It appears that a compiler error limits you to an actual value of 6,663. In the "real world", having more than 5-10 classes should be a sign that you should probably refactor and/or extract some classes in other other classes or top-level classes. The exception to this rule of thumb would be automatically generated code, such as WSDL2Apex, or JSON2Apex.
answered 2 days ago
sfdcfoxsfdcfox
282k14 gold badges231 silver badges483 bronze badges
282k14 gold badges231 silver badges483 bronze badges
add a comment |
add a comment |
1
Welcome to SFSE! Please take the tour and read How to Ask. I don't think there's any practical limit here, but I doubt there's documentation to back that up. This question, though, gives me an X-Y Problem vibe. I get the feeling that you either have a class with a bunch of inner classes and are running into an issue, or are trying to solve a problem and think that using a bunch of inner classes is the answer. Either way, the best way to get help from this community is to provide us with lots of details. What is your problem? How are you trying to solve it?
– Derek F
Aug 17 at 23:05
If you're getting an error message, providing the full error message, verbatim, really helps. The more relevant detail you can give us, the better we'll be able to understand your situation. Ultimately, that should end up getting you more useful and accurate answers.
– Derek F
Aug 17 at 23:09
2
And, for what it's worth, I've personally had somewhere between 12 - 36 inner classes contained in a single outer class (mostly just to help deserialize payloads from an external system). Haven't really counted the exact number.
– Derek F
Aug 17 at 23:14