English 中文(简体)
动态的班级重载只用精减的方式操作,为什么/如何操作?
原标题:Dynamic class reloading works only in debug mode, why/ how it really works?

我有一个trick切的问题。

我的java方案正在从事这样的活动:

住宿:

  1. 阅读外部档案,将java类编成沥青阵列。

  2. 创立了一个由我自己的舱载体组成的新例子。

  3. 从阅读的档案中排入该舱载体。

  4. 使用制造的舱载体从外部档案中产生新种类的物体。

  5. 系指制造物体的任何方法。

And where the problem is.

  1. When I run this program in debug mode it behaves as I expect, so if external file changed classloader loads new version of class and executes new version (if file didn t change it loads old version also of course).

  2. But when I run this program NOT in a debug mode it always executes old version despite the fact that the readed file has changed.

也许有人更深入地了解轮班问题,而多国公司的行为可以向我解释这种行为。

最佳回答

Here s a simplified version of what happens:

  1. The JVM loads classes and other resources into the classpath exactly once (unless running in debug mode) from the directories or Jars specified in the CLASSPATH environment variable.
  2. To do this, it uses ClassLoaders
  3. Once a resource has been loaded by a ClassLoader instance, it remains in memory until the ClassLoader is garbage collected.

减速模式是国际交易日志提供的一种特殊模式,舱载人更努力地向您提供最新版本的资源。

问题回答

不可能用同级装载机重载同一类别。

you can find a well written article about dynamic class re/loading here





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签