Some Confusion about the source code of Tomcat

Some day before, I began to read the source code of the tomcat

First, the server starts from the main method in the org.apache.catalina.startup.BootStrap, but when I go into the code bootstrap.init(),
and I was confused by the following code.Like:

Just for easy to debug the tomcat, I change the code like this:

The code can still work. And in the Tomcat source code, there are many code block like this, For example,in org.apache.catalina.startup.BootStrap.start() we can find the following code:

Still for easy to debug, I turn the code into:

The code still works fine.So I was confused, Here are my questions.

  1. what’s difference between the two kinds of code?
  2. Why the coder of Tomcat do not write the code like what I write? what’s the benefit?
  3. If the Tomcat with my kind code works in a production environment, what will happen or nothing will happen?

Any answers or advice should be grateful.

3 Replies to “Some Confusion about the source code of Tomcat”

    1. @ming:我对此的理解是,假如我们有两个程序员,一个在写程序的时候,需要使用第二个人所写的类,但第二个程序员并没完成他所写的类。那么第一个人的代码不能通过编译。利用Java反射的机制,就可以让第一个程序员在没有得到第二个程序员所写的类的时候,来完成自身代码的编译。

Leave a Reply

Your email address will not be published. Required fields are marked *