diff --git a/.gitignore b/.gitignore index 2652217..75d9853 100644 --- a/.gitignore +++ b/.gitignore @@ -36,5 +36,5 @@ hs_err_pid* /lista02/lista02-ex03/target/ /lista02/ex02/ex01/nbproject/private/ /lista03/ex01/ex01/nbproject/private/ -/lista05/ex03/MinhaListaEncadeada/nbproject/private/ -/lista05/ex03/MinhaListaEncadeada/build/ +/lista05/lista05ex04/lista05ex04/nbproject/private/ +/lista05/lista05ex04/lista05ex04/build/ diff --git a/lista05/ex01/pom.xml b/lista05/ex01/pom.xml new file mode 100644 index 0000000..c0f0ccc --- /dev/null +++ b/lista05/ex01/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + com.scc0604 + ex01 + 1.0-SNAPSHOT + jar + + UTF-8 + 18 + 18 + Ex01 + + \ No newline at end of file diff --git a/lista05/ex01/src/main/java/Ex01.java b/lista05/ex01/src/main/java/Ex01.java new file mode 100644 index 0000000..9272d77 --- /dev/null +++ b/lista05/ex01/src/main/java/Ex01.java @@ -0,0 +1,9 @@ +public class Ex01 { + + public static void main(String[] args) { + MeuVetorDinamico vetor = new MeuVetorDinamico(10); + vetor.Preencher(); + vetor.Inserir(50, 0); + vetor.Imprimir(); + } +} diff --git a/lista05/ex01/src/main/java/MeuVetorDinamico.java b/lista05/ex01/src/main/java/MeuVetorDinamico.java new file mode 100644 index 0000000..377bba5 --- /dev/null +++ b/lista05/ex01/src/main/java/MeuVetorDinamico.java @@ -0,0 +1,30 @@ +public class MeuVetorDinamico { + int[] vetorDinamico; + int tamanho; + + public MeuVetorDinamico(int tamanho){ + this.tamanho = tamanho; + vetorDinamico = new int[this.tamanho]; + + for(int i = 0; i < this.tamanho; i++){ + vetorDinamico[i] = 0; + } + } + + public void Inserir(int valor, int i){ + vetorDinamico[i] = valor; + } + + public void Preencher(){ + for(int i = 0; i < tamanho; i++){ + vetorDinamico[i] = 100 * i; + } + } + + public void Imprimir(){ + for(int i = 0; i < tamanho; i++){ + System.out.print(vetorDinamico[i] + ", "); + } + System.out.println(" "); + } +} diff --git a/lista05/ex02/build.xml b/lista05/ex02/build.xml new file mode 100644 index 0000000..a1f66bd --- /dev/null +++ b/lista05/ex02/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project ex02. + + + diff --git a/lista05/ex02/manifest.mf b/lista05/ex02/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/lista05/ex02/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/lista05/ex02/nbproject/build-impl.xml b/lista05/ex02/nbproject/build-impl.xml new file mode 100644 index 0000000..0db2c8b --- /dev/null +++ b/lista05/ex02/nbproject/build-impl.xml @@ -0,0 +1,1799 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set platform.home + Must set platform.bootcp + Must set platform.java + Must set platform.javac + + The J2SE Platform is not correctly set up. + Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. + Either open the project in the IDE and setup the Platform with the same name or add it manually. + For example like this: + ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) + or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + ${platform.java} -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lista05/ex02/nbproject/genfiles.properties b/lista05/ex02/nbproject/genfiles.properties new file mode 100644 index 0000000..467efe3 --- /dev/null +++ b/lista05/ex02/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=fdb976dd +build.xml.script.CRC32=06918774 +build.xml.stylesheet.CRC32=f85dc8f2@1.104.0.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=fdb976dd +nbproject/build-impl.xml.script.CRC32=ee5199cc +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.104.0.48 diff --git a/lista05/ex02/nbproject/project.properties b/lista05/ex02/nbproject/project.properties new file mode 100644 index 0000000..27db77b --- /dev/null +++ b/lista05/ex02/nbproject/project.properties @@ -0,0 +1,95 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ex02.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/ex02 +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=ex02 +main.class=ex02.Ex02 +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=Zulu_8.0.345_1 +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/lista05/ex02/nbproject/project.xml b/lista05/ex02/nbproject/project.xml new file mode 100644 index 0000000..e9bad6a --- /dev/null +++ b/lista05/ex02/nbproject/project.xml @@ -0,0 +1,16 @@ + + + org.netbeans.modules.java.j2seproject + + + ex02 + + + + + + + + + + diff --git a/lista05/ex02/src/ex02/Ex02.java b/lista05/ex02/src/ex02/Ex02.java new file mode 100644 index 0000000..f65e2cc --- /dev/null +++ b/lista05/ex02/src/ex02/Ex02.java @@ -0,0 +1,30 @@ +package ex02; + +public class Ex02 { + + public static void main(String[] args) { + // Cria classe MinhaMatrizDinamica + MinhaMatrizDinamica ma = new MinhaMatrizDinamica(5, 5); + + // Imprime na tela matriz + System.out.println("Matriz inicializada com zeros:"); + System.out.print(ma); + + // Preenche a diagonal principal com o valor 42 + for(int i = 0; i < 5; i++) { + ma.preenchePosicao(i, i, 42); + } + + // Imprime na tela matriz + System.out.println("Matriz com a diagonal principal preenchida:"); + System.out.print(ma); + + // Preenche cada elemento da matriz com a soma dos indexes + ma.preencheComSomaDeIndexes(); + + // Imprime a matriz + System.out.println("Matriz com elementos = i + j"); + System.out.print(ma); + } + +} diff --git a/lista05/ex02/src/ex02/MinhaMatrizDinamica.java b/lista05/ex02/src/ex02/MinhaMatrizDinamica.java new file mode 100644 index 0000000..5e1bc5c --- /dev/null +++ b/lista05/ex02/src/ex02/MinhaMatrizDinamica.java @@ -0,0 +1,51 @@ +package ex02; + +import java.util.ArrayList; + +public class MinhaMatrizDinamica { + private ArrayList> matriz = new ArrayList>(); + private int numLinhas; + private int numColunas; + + private void inicializa(int valor) { + for(int i = 0; i < numLinhas; i++) { + ArrayList nova_linha = new ArrayList(); + for(int j = 0; j < numColunas; j++) { + nova_linha.add(valor); + } + this.matriz.add(nova_linha); + } + } + + public void preenchePosicao(int linha, int coluna, int valor) { + this.matriz.get(linha).set(coluna, valor); + } + + public void preencheComSomaDeIndexes() { + for(int i = 0; i < numLinhas; i++) { + for(int j = 0; j < numColunas; j++) { + this.preenchePosicao(i, j, i + j); + } + } + } + + MinhaMatrizDinamica(int numLinhas, int numColunas) { + this.numColunas = numColunas; + this.numLinhas = numLinhas; + + this.inicializa(0); + } + + @Override + public String toString() { + String matrix_plain_text = new String(); + + for(ArrayList linha: this.matriz) { + for(Integer elemento: linha) { + matrix_plain_text += elemento.toString() + " "; + } + matrix_plain_text += "\n"; + } + return matrix_plain_text; + } +} diff --git a/lista05/lista05ex04/ex04.txt b/lista05/lista05ex04/ex04.txt new file mode 100644 index 0000000..f3caa9c --- /dev/null +++ b/lista05/lista05ex04/ex04.txt @@ -0,0 +1,31 @@ +Explicação da estratégia aplicada para causar o erro java.lang.StackOverflowError: + + +Parâmetros e variáveis locais são alocados na stack. A stack tem uma quantidade fixa de memória, caso essa memória se esgote, um erro de StackOverflow acontecerá. No exercício foi pedido para que criássemos um código que propositalmente causasse o erro de stackOverflow. + Então foi criado um código muito simples com um método que chama a si mesmo (recursão) infinitamente sem nenhum critério de parada e que manda um parâmetro (i) para si. Esse parâmetro fica salvo na stack a cada chamada, e como as chamadas ocorrem infinitamente, a stack se esgota, causando o erro java.lang.Stack.OverflowError. +Log do erro: + +Exception in thread "main" java.lang.StackOverflowError + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + /home/cillor/.cache/netbeans/15/executor-snippets/run.xml:111: The following error occurred while executing this line: +/home/cillor/.cache/netbeans/15/executor-snippets/run.xml:68: Java returned: 1 +BUILD FAILED (total time: 0 seconds) diff --git a/lista05/lista05ex04/lista05ex04/build.xml b/lista05/lista05ex04/lista05ex04/build.xml new file mode 100644 index 0000000..2c0085c --- /dev/null +++ b/lista05/lista05ex04/lista05ex04/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project lista05ex04. + + + diff --git a/lista05/lista05ex04/lista05ex04/manifest.mf b/lista05/lista05ex04/lista05ex04/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/lista05/lista05ex04/lista05ex04/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/lista05/lista05ex04/lista05ex04/nbproject/build-impl.xml b/lista05/lista05ex04/lista05ex04/nbproject/build-impl.xml new file mode 100644 index 0000000..2a395f7 --- /dev/null +++ b/lista05/lista05ex04/lista05ex04/nbproject/build-impl.xml @@ -0,0 +1,1771 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lista05/lista05ex04/lista05ex04/nbproject/genfiles.properties b/lista05/lista05ex04/lista05ex04/nbproject/genfiles.properties new file mode 100644 index 0000000..1949c9b --- /dev/null +++ b/lista05/lista05ex04/lista05ex04/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=136cb60c +build.xml.script.CRC32=5cb18bf1 +build.xml.stylesheet.CRC32=f85dc8f2@1.104.0.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=136cb60c +nbproject/build-impl.xml.script.CRC32=a48487b6 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.104.0.48 diff --git a/lista05/lista05ex04/lista05ex04/nbproject/project.properties b/lista05/lista05ex04/lista05ex04/nbproject/project.properties new file mode 100644 index 0000000..b6deafd --- /dev/null +++ b/lista05/lista05ex04/lista05ex04/nbproject/project.properties @@ -0,0 +1,95 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/lista05ex04.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/lista05ex04 +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=18 +javac.target=18 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=lista05ex04 +main.class=lista05ex04.Lista05ex04 +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/lista05/lista05ex04/lista05ex04/nbproject/project.xml b/lista05/lista05ex04/lista05ex04/nbproject/project.xml new file mode 100644 index 0000000..cf787a6 --- /dev/null +++ b/lista05/lista05ex04/lista05ex04/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + lista05ex04 + + + + + + + + + diff --git a/lista05/lista05ex04/lista05ex04/src/lista05ex04/Lista05ex04.java b/lista05/lista05ex04/lista05ex04/src/lista05ex04/Lista05ex04.java new file mode 100644 index 0000000..d1ca15e --- /dev/null +++ b/lista05/lista05ex04/lista05ex04/src/lista05ex04/Lista05ex04.java @@ -0,0 +1,47 @@ +package lista05ex04; + +public class Lista05ex04 { + + public static void main(String[] args) { + DoStackOverflow(1); + // TODO code application logic here + } + + public static void DoStackOverflow(int i) { + DoStackOverflow(i); + } + +} +/* Explicação da estratégia aplicada para causar o erro java.lang.StackOverflowError: + + +Parâmetros e variáveis locais são alocados na stack. A stack tem uma quantidade fixa de memória, caso essa memória se esgote, um erro de StackOverflow acontecerá. No exercício foi pedido para que criássemos um código que propositalmente causasse o erro de stackOverflow. + Então foi criado um código muito simples com um método que chama a si mesmo (recursão) infinitamente sem nenhum critério de parada e que manda um parâmetro (i) para si. Esse parâmetro fica salvo na stack a cada chamada, e como as chamadas ocorrem infinitamente, a stack se esgota, causando o erro java.lang.Stack.OverflowError. +Log do erro: + +Exception in thread "main" java.lang.StackOverflowError + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + at lista05ex04.Lista05ex04.DoStackOverflow(Lista05ex04.java:11) + /home/cillor/.cache/netbeans/15/executor-snippets/run.xml:111: The following error occurred while executing this line: +/home/cillor/.cache/netbeans/15/executor-snippets/run.xml:68: Java returned: 1 +BUILD FAILED (total time: 0 seconds) + +*/